| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.non_error_resolver_test; | 5 library engine.non_error_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | |
| 10 import 'package:analyzer/src/generated/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 11 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 12 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
| 13 import 'package:unittest/unittest.dart' as _ut; | 12 import 'package:unittest/unittest.dart' as _ut; |
| 14 | 13 |
| 15 import '../reflective_tests.dart'; | 14 import '../reflective_tests.dart'; |
| 16 import 'resolver_test.dart'; | 15 import 'resolver_test.dart'; |
| 17 import 'test_support.dart'; | 16 import 'test_support.dart'; |
| 18 | 17 |
| 19 main() { | 18 main() { |
| (...skipping 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4995 } | 4994 } |
| 4996 class Bar extends Foo { | 4995 class Bar extends Foo { |
| 4997 Bar() : this.ctor(); | 4996 Bar() : this.ctor(); |
| 4998 Bar.ctor() : super.ctor(); | 4997 Bar.ctor() : super.ctor(); |
| 4999 }'''); | 4998 }'''); |
| 5000 computeLibrarySourceErrors(source); | 4999 computeLibrarySourceErrors(source); |
| 5001 assertNoErrors(source); | 5000 assertNoErrors(source); |
| 5002 verify([source]); | 5001 verify([source]); |
| 5003 } | 5002 } |
| 5004 | 5003 |
| 5005 void test_undefinedGetter_typeLiteral_conditionalAccess() { | 5004 void test_undefinedGetter_static_conditionalAccess() { |
| 5006 // When applied to a type literal, the conditional access operator '?.' can | 5005 // The conditional access operator '?.' can be used to access static |
| 5007 // be used to access instance getters of Type. | 5006 // fields. |
| 5008 Source source = addSource(''' | 5007 Source source = addSource(''' |
| 5009 class A {} | 5008 class A { |
| 5010 f() => A?.hashCode; | 5009 static var x; |
| 5010 } |
| 5011 var a = A?.x; |
| 5011 '''); | 5012 '''); |
| 5012 computeLibrarySourceErrors(source); | 5013 computeLibrarySourceErrors(source); |
| 5013 assertNoErrors(source); | 5014 assertNoErrors(source); |
| 5014 verify([source]); | 5015 verify([source]); |
| 5015 } | 5016 } |
| 5016 | 5017 |
| 5017 void test_undefinedGetter_typeSubstitution() { | 5018 void test_undefinedGetter_typeSubstitution() { |
| 5018 Source source = addSource(r''' | 5019 Source source = addSource(r''' |
| 5019 class A<E> { | 5020 class A<E> { |
| 5020 E element; | 5021 E element; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5082 void test_undefinedMethod_functionExpression_directCall() { | 5083 void test_undefinedMethod_functionExpression_directCall() { |
| 5083 Source source = addSource(r''' | 5084 Source source = addSource(r''' |
| 5084 main() { | 5085 main() { |
| 5085 (() => null)(); | 5086 (() => null)(); |
| 5086 }'''); | 5087 }'''); |
| 5087 computeLibrarySourceErrors(source); | 5088 computeLibrarySourceErrors(source); |
| 5088 assertNoErrors(source); | 5089 assertNoErrors(source); |
| 5089 // A call to verify(source) fails as '(() => null)()' isn't resolved. | 5090 // A call to verify(source) fails as '(() => null)()' isn't resolved. |
| 5090 } | 5091 } |
| 5091 | 5092 |
| 5092 void test_undefinedMethod_typeLiteral_conditionalAccess() { | 5093 void test_undefinedMethod_static_conditionalAccess() { |
| 5093 // When applied to a type literal, the conditional access operator '?.' can | 5094 // The conditional access operator '?.' can be used to access static |
| 5094 // be used to access instance methods of Type. | 5095 // methods. |
| 5095 Source source = addSource(''' | 5096 Source source = addSource(''' |
| 5096 class A {} | 5097 class A { |
| 5097 f() => A?.toString(); | 5098 static void m() {} |
| 5099 } |
| 5100 f() { A?.m(); } |
| 5098 '''); | 5101 '''); |
| 5099 computeLibrarySourceErrors(source); | 5102 computeLibrarySourceErrors(source); |
| 5100 assertNoErrors(source); | 5103 assertNoErrors(source); |
| 5101 verify([source]); | 5104 verify([source]); |
| 5102 } | 5105 } |
| 5103 | 5106 |
| 5104 void test_undefinedOperator_index() { | 5107 void test_undefinedOperator_index() { |
| 5105 Source source = addSource(r''' | 5108 Source source = addSource(r''' |
| 5106 class A { | 5109 class A { |
| 5107 operator [](a) {} | 5110 operator [](a) {} |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5132 Source source = addSource(r''' | 5135 Source source = addSource(r''' |
| 5133 import 'lib.dart' as x; | 5136 import 'lib.dart' as x; |
| 5134 main() { | 5137 main() { |
| 5135 x.y = 0; | 5138 x.y = 0; |
| 5136 }'''); | 5139 }'''); |
| 5137 computeLibrarySourceErrors(source); | 5140 computeLibrarySourceErrors(source); |
| 5138 assertNoErrors(source); | 5141 assertNoErrors(source); |
| 5139 verify([source]); | 5142 verify([source]); |
| 5140 } | 5143 } |
| 5141 | 5144 |
| 5145 void test_undefinedSetter_static_conditionalAccess() { |
| 5146 // The conditional access operator '?.' can be used to access static |
| 5147 // fields. |
| 5148 Source source = addSource(''' |
| 5149 class A { |
| 5150 static var x; |
| 5151 } |
| 5152 f() { A?.x = 1; } |
| 5153 '''); |
| 5154 computeLibrarySourceErrors(source); |
| 5155 assertNoErrors(source); |
| 5156 verify([source]); |
| 5157 } |
| 5158 |
| 5142 void test_undefinedSuperMethod_field() { | 5159 void test_undefinedSuperMethod_field() { |
| 5143 Source source = addSource(r''' | 5160 Source source = addSource(r''' |
| 5144 class A { | 5161 class A { |
| 5145 var m; | 5162 var m; |
| 5146 } | 5163 } |
| 5147 class B extends A { | 5164 class B extends A { |
| 5148 f() { | 5165 f() { |
| 5149 super.m(); | 5166 super.m(); |
| 5150 } | 5167 } |
| 5151 }'''); | 5168 }'''); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5518 reset(); | 5535 reset(); |
| 5519 } | 5536 } |
| 5520 | 5537 |
| 5521 void _check_wrongNumberOfParametersForOperator1(String name) { | 5538 void _check_wrongNumberOfParametersForOperator1(String name) { |
| 5522 _check_wrongNumberOfParametersForOperator(name, "a"); | 5539 _check_wrongNumberOfParametersForOperator(name, "a"); |
| 5523 } | 5540 } |
| 5524 | 5541 |
| 5525 CompilationUnit _getResolvedLibraryUnit(Source source) => | 5542 CompilationUnit _getResolvedLibraryUnit(Source source) => |
| 5526 analysisContext.getResolvedCompilationUnit2(source, source); | 5543 analysisContext.getResolvedCompilationUnit2(source, source); |
| 5527 } | 5544 } |
| OLD | NEW |