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 analyzer.test.generated.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 expect(functions[0].enclosingElement, constructor); | 217 expect(functions[0].enclosingElement, constructor); |
218 assertErrors(source, [ParserErrorCode.GETTER_IN_FUNCTION]); | 218 assertErrors(source, [ParserErrorCode.GETTER_IN_FUNCTION]); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 /** | 222 /** |
223 * Tests for generic method and function resolution that do not use strong mode. | 223 * Tests for generic method and function resolution that do not use strong mode. |
224 */ | 224 */ |
225 @reflectiveTest | 225 @reflectiveTest |
226 class GenericMethodResolverTest extends StaticTypeAnalyzer2TestShared { | 226 class GenericMethodResolverTest extends StaticTypeAnalyzer2TestShared { |
227 void setUp() { | |
228 super.setUp(); | |
229 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
230 options.enableGenericMethods = true; | |
231 resetWithOptions(options); | |
232 } | |
233 | |
234 void test_genericMethod_propagatedType_promotion() { | 227 void test_genericMethod_propagatedType_promotion() { |
235 // Regression test for: | 228 // Regression test for: |
236 // https://github.com/dart-lang/sdk/issues/25340 | 229 // https://github.com/dart-lang/sdk/issues/25340 |
237 // | 230 // |
238 // Note, after https://github.com/dart-lang/sdk/issues/25486 the original | 231 // Note, after https://github.com/dart-lang/sdk/issues/25486 the original |
239 // strong mode example won't work, as we now compute a static type and | 232 // strong mode example won't work, as we now compute a static type and |
240 // therefore discard the propagated type. | 233 // therefore discard the propagated type. |
241 // | 234 // |
242 // So this test does not use strong mode. | 235 // So this test does not use strong mode. |
243 resolveTestUnit(r''' | 236 resolveTestUnit(r''' |
(...skipping 3330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 node.accept(_visitor); | 3567 node.accept(_visitor); |
3575 } | 3568 } |
3576 | 3569 |
3577 /** | 3570 /** |
3578 * Parse the given [code], build elements and resolve in the | 3571 * Parse the given [code], build elements and resolve in the |
3579 * [TypeResolverMode.local] mode. The [code] is allowed to use only the type | 3572 * [TypeResolverMode.local] mode. The [code] is allowed to use only the type |
3580 * named `A`. | 3573 * named `A`. |
3581 */ | 3574 */ |
3582 void _resolveTypeModeLocal( | 3575 void _resolveTypeModeLocal( |
3583 String code, AstNode getNodeToResolve(CompilationUnit unit)) { | 3576 String code, AstNode getNodeToResolve(CompilationUnit unit)) { |
3584 CompilationUnit unit = | 3577 CompilationUnit unit = ParserTestCase.parseCompilationUnit2(code); |
3585 ParserTestCase.parseCompilationUnit2(code, parseGenericMethods: true); | |
3586 var unitElement = new CompilationUnitElementImpl('/test.dart'); | 3578 var unitElement = new CompilationUnitElementImpl('/test.dart'); |
3587 | 3579 |
3588 // Build API elements. | 3580 // Build API elements. |
3589 { | 3581 { |
3590 var holder = new ElementHolder(); | 3582 var holder = new ElementHolder(); |
3591 unit.accept(new ElementBuilder(holder, unitElement)); | 3583 unit.accept(new ElementBuilder(holder, unitElement)); |
3592 } | 3584 } |
3593 | 3585 |
3594 // Prepare for resolution. | 3586 // Prepare for resolution. |
3595 LibraryScope libraryScope; | 3587 LibraryScope libraryScope; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 */ | 3623 */ |
3632 class _StaleElement extends ElementImpl { | 3624 class _StaleElement extends ElementImpl { |
3633 _StaleElement() : super("_StaleElement", -1); | 3625 _StaleElement() : super("_StaleElement", -1); |
3634 | 3626 |
3635 @override | 3627 @override |
3636 get kind => throw "_StaleElement's kind shouldn't be accessed"; | 3628 get kind => throw "_StaleElement's kind shouldn't be accessed"; |
3637 | 3629 |
3638 @override | 3630 @override |
3639 accept(_) => throw "_StaleElement shouldn't be visited"; | 3631 accept(_) => throw "_StaleElement shouldn't be visited"; |
3640 } | 3632 } |
OLD | NEW |