| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 void main () { | 674 void main () { |
| 675 var x = 3; | 675 var x = 3; |
| 676 List<int> l0 = []; | 676 List<int> l0 = []; |
| 677 } | 677 } |
| 678 '''); | 678 '''); |
| 679 resolve2(source); | 679 resolve2(source); |
| 680 assertNoErrors(source); | 680 assertNoErrors(source); |
| 681 verify([source]); | 681 verify([source]); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void test_inferredFieldDeclaration_propagation() { |
| 685 // Regression test for https://github.com/dart-lang/sdk/issues/25546 |
| 686 String code = r''' |
| 687 abstract class A { |
| 688 Map<int, List<int>> get map; |
| 689 } |
| 690 class B extends A { |
| 691 var map = { 42: [] }; |
| 692 } |
| 693 class C extends A { |
| 694 get map => { 43: [] }; |
| 695 } |
| 696 '''; |
| 697 CompilationUnit unit = resolveSource(code); |
| 698 |
| 699 Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt); |
| 700 Asserter<InterfaceType> assertMapOfIntToListOfInt = |
| 701 _isMapOf(_isInt, assertListOfInt); |
| 702 |
| 703 VariableDeclaration mapB = AstFinder.getFieldInClass(unit, "B", "map"); |
| 704 MethodDeclaration mapC = AstFinder.getMethodInClass(unit, "C", "map"); |
| 705 assertMapOfIntToListOfInt(mapB.element.type); |
| 706 assertMapOfIntToListOfInt(mapC.element.returnType); |
| 707 |
| 708 MapLiteral mapLiteralB = mapB.initializer; |
| 709 MapLiteral mapLiteralC = (mapC.body as ExpressionFunctionBody).expression; |
| 710 assertMapOfIntToListOfInt(mapLiteralB.staticType); |
| 711 assertMapOfIntToListOfInt(mapLiteralC.staticType); |
| 712 |
| 713 ListLiteral listLiteralB = mapLiteralB.entries[0].value; |
| 714 ListLiteral listLiteralC = mapLiteralC.entries[0].value; |
| 715 assertListOfInt(listLiteralB.staticType); |
| 716 assertListOfInt(listLiteralC.staticType); |
| 717 } |
| 718 |
| 684 void test_instanceCreation() { | 719 void test_instanceCreation() { |
| 685 String code = r''' | 720 String code = r''' |
| 686 class A<S, T> { | 721 class A<S, T> { |
| 687 S x; | 722 S x; |
| 688 T y; | 723 T y; |
| 689 A(this.x, this.y); | 724 A(this.x, this.y); |
| 690 A.named(this.x, this.y); | 725 A.named(this.x, this.y); |
| 691 } | 726 } |
| 692 | 727 |
| 693 class B<S, T> extends A<T, S> { | 728 class B<S, T> extends A<T, S> { |
| (...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2268 main() { | 2303 main() { |
| 2269 var v = x; | 2304 var v = x; |
| 2270 v; // marker | 2305 v; // marker |
| 2271 } | 2306 } |
| 2272 int x = 3; | 2307 int x = 3; |
| 2273 '''; | 2308 '''; |
| 2274 assertPropagatedAssignedType(code, typeProvider.intType, null); | 2309 assertPropagatedAssignedType(code, typeProvider.intType, null); |
| 2275 assertTypeOfMarkedExpression(code, typeProvider.intType, null); | 2310 assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
| 2276 } | 2311 } |
| 2277 } | 2312 } |
| OLD | NEW |