Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Unified Diff: tests/language/if_null_assignment_static_test.dart

Issue 1062723002: Implement the new '?.' operator in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bump analyzer version. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
+ }
}

Powered by Google App Engine
This is Rietveld 408576698