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

Unified Diff: pkg/analyzer/test/generated/static_type_warning_code_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: pkg/analyzer/test/generated/static_type_warning_code_test.dart
diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
index 02eca6e174b7399266ec1b10e455e0a409126d9a..061c69d12662b4a2d479edf286fd63c6a156cb7e 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -1397,6 +1397,22 @@ var a = A.B;''');
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
+ void test_undefinedGetter_static_conditionalAccess() {
+ // The conditional access operator '?.' cannot be used to access static
+ // fields.
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.enableNullAwareOperators = true;
+ resetWithOptions(options);
+ Source source = addSource('''
+class A {
+ static var x;
+}
+var a = A?.x;
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
Brian Wilkerson 2015/04/05 19:55:45 It would be good to use a less generic error code,
Paul Berry 2015/04/05 20:49:43 That's a good point, especially given that this li
+ }
+
void test_undefinedGetter_void() {
Source source = addSource(r'''
class T {
@@ -1549,6 +1565,22 @@ main() {
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
}
+ void test_undefinedMethod_static_conditionalAccess() {
+ // The conditional access operator '?.' cannot be used to access static
+ // methods.
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.enableNullAwareOperators = true;
+ resetWithOptions(options);
+ Source source = addSource('''
+class A {
+ static void m() {}
+}
+f() { A?.m(); }
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
+ }
+
void test_undefinedOperator_indexBoth() {
Source source = addSource(r'''
class A {}
@@ -1625,6 +1657,22 @@ f() { A.B = 0;}''');
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
+ void test_undefinedSetter_static_conditionalAccess() {
+ // The conditional access operator '?.' cannot be used to access static
+ // fields.
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.enableNullAwareOperators = true;
+ resetWithOptions(options);
+ Source source = addSource('''
+class A {
+ static var x;
+}
+f() { A?.x = 1; }
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
+ }
+
void test_undefinedSetter_void() {
Source source = addSource(r'''
class T {

Powered by Google App Engine
This is Rietveld 408576698