Index: tests/language/if_null_assignment_static_test.dart |
diff --git a/tests/language/if_null_assignment_static_test.dart b/tests/language/if_null_assignment_static_test.dart |
index a6f8c8b95a38d6ee33a4a6882ce965dff1becf66..03739c461a7a98af28cfa42ba0805e4f41990af0 100644 |
--- a/tests/language/if_null_assignment_static_test.dart |
+++ b/tests/language/if_null_assignment_static_test.dart |
@@ -157,4 +157,20 @@ main() { |
// also generated in the case of e1[e2] ??= e3. |
(<B>[null])[0] ??= new C(); /// 35: static type warning |
} |
+ |
+ // The static type of e1?.v op= e2 is the static type of e1.v op e2, |
+ // therefore the static type of e1?.v ??= e2 is the static type of |
+ // e1.v ?? e2, which is the LUB of the static types of e1?.v and e2. |
+ (new ClassWithInstanceGetters()?.a ??= new A()).a; /// 36: ok |
+ Expect.throws(() => (new ClassWithInstanceGetters()?.a ??= new A()).b, noMethod); /// 37: static type warning |
+ (new ClassWithInstanceGetters()?.a ??= new B()).a; /// 38: ok |
+ (new ClassWithInstanceGetters()?.a ??= new B()).b; /// 39: static type warning |
+ if (!checkedMode) { |
+ (new ClassWithInstanceGetters()?.b ??= new A()).a; /// 40: ok |
+ Expect.throws(() => (new ClassWithInstanceGetters()?.b ??= new A()).b, noMethod); /// 41: static type warning |
+ |
+ // Exactly the same static warnings that would be caused by e1.v ??= e2 are |
+ // also generated in the case of e1?.v ??= e2. |
+ new ClassWithInstanceGetters()?.b ??= new C(); /// 42: static type warning |
+ } |
} |