Chromium Code Reviews| 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 { |