|
@@ -69,6 +69,76 @@ class TestNullChecker extends TestBase {
|
|
|
@:analyzer(testIsNotNull) ns;
|
|
|
}
|
|
|
|
|
|
+ function testReturn1() {
|
|
|
+ var ns = getNullString();
|
|
|
+ if (ns == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNotNull) ns;
|
|
|
+ }
|
|
|
+
|
|
|
+ function testReturn2() {
|
|
|
+ var ns = getNullString();
|
|
|
+ if (ns != null) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNotNull) ns;
|
|
|
+ }
|
|
|
+
|
|
|
+ // doesn't work yet due to || transformation
|
|
|
+ //function testReturn3() {
|
|
|
+ //var ns = getNullString();
|
|
|
+ //if (ns == null || getTrue()) {
|
|
|
+ //return;
|
|
|
+ //}
|
|
|
+ //@:analyzer(testIsNotNull) ns;
|
|
|
+ //}
|
|
|
+
|
|
|
+ function testReturn4() {
|
|
|
+ var ns = getNullString();
|
|
|
+ if (ns != null && getTrue()) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNull) ns;
|
|
|
+ }
|
|
|
+
|
|
|
+ function testBreak() {
|
|
|
+ var ns = getNullString();
|
|
|
+ while (true) {
|
|
|
+ if (ns == null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNotNull) ns;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNull) ns;
|
|
|
+ }
|
|
|
+
|
|
|
+ function testContinue() {
|
|
|
+ var ns = getNullString();
|
|
|
+ while (true) {
|
|
|
+ if (getTrue()) {
|
|
|
+ break; // to terminate
|
|
|
+ }
|
|
|
+ if (ns == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNotNull) ns;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNull) ns;
|
|
|
+ }
|
|
|
+
|
|
|
+ function testThrow() {
|
|
|
+ var ns = getNotNullString();
|
|
|
+ if (ns == null) {
|
|
|
+ throw false;
|
|
|
+ }
|
|
|
+ @:analyzer(testIsNotNull) ns;
|
|
|
+ }
|
|
|
+
|
|
|
function getString() {
|
|
|
return "foo";
|
|
|
}
|
|
@@ -76,4 +146,16 @@ class TestNullChecker extends TestBase {
|
|
|
function getNullString():Null<String> {
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ function getNotNullString():Null<String> {
|
|
|
+ return "foo";
|
|
|
+ }
|
|
|
+
|
|
|
+ function getTrue() {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ function getFalse() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|