| 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 import 'package:analyzer/dart/element/type.dart'; | 5 import 'package:analyzer/dart/element/type.dart'; |
| 6 import 'package:analyzer/src/dart/element/element.dart'; | 6 import 'package:analyzer/src/dart/element/element.dart'; |
| 7 import 'package:analyzer/src/summary/format.dart'; | 7 import 'package:analyzer/src/summary/format.dart'; |
| 8 import 'package:analyzer/src/summary/idl.dart'; | 8 import 'package:analyzer/src/summary/idl.dart'; |
| 9 import 'package:analyzer/src/summary/link.dart'; | 9 import 'package:analyzer/src/summary/link.dart'; |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 createLinker('import "a.dart"; var b = a;', path: '/b.dart'); | 634 createLinker('import "a.dart"; var b = a;', path: '/b.dart'); |
| 635 expect( | 635 expect( |
| 636 _getVariable(linker | 636 _getVariable(linker |
| 637 .getLibrary(linkerInputs.testDartUri) | 637 .getLibrary(linkerInputs.testDartUri) |
| 638 .getContainedName('b')) | 638 .getContainedName('b')) |
| 639 .inferredType | 639 .inferredType |
| 640 .toString(), | 640 .toString(), |
| 641 'int'); | 641 'int'); |
| 642 } | 642 } |
| 643 | 643 |
| 644 void test_inheritsCovariant_fromBundle() { |
| 645 var bundle = createPackageBundle(''' |
| 646 class X1 {} |
| 647 class X2 extends X1 {} |
| 648 class A { |
| 649 void foo(covariant X1 x) {} |
| 650 } |
| 651 class B extends A { |
| 652 void foo(X2 x) {} |
| 653 } |
| 654 ''', path: '/a.dart'); |
| 655 addBundle('/a.ds', bundle); |
| 656 |
| 657 // C.foo.x must inherit covariance from B.foo.x, even though it is |
| 658 // resynthesized from the bundle. |
| 659 createLinker(''' |
| 660 import 'a.dart'; |
| 661 class C extends B { |
| 662 void foo(X2 x) {} |
| 663 } |
| 664 '''); |
| 665 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 666 library.libraryCycleForLink.ensureLinked(); |
| 667 |
| 668 ClassElementForLink_Class C = library.getContainedName('C'); |
| 669 expect(C.methods, hasLength(1)); |
| 670 MethodElementForLink foo = C.methods[0]; |
| 671 expect(foo.parameters, hasLength(1)); |
| 672 expect(foo.parameters[0].isCovariant, isTrue); |
| 673 } |
| 674 |
| 644 void test_instantiate_param_of_param_to_bounds() { | 675 void test_instantiate_param_of_param_to_bounds() { |
| 645 createLinker(''' | 676 createLinker(''' |
| 646 class C<T> {} | 677 class C<T> {} |
| 647 class D<T extends num> {} | 678 class D<T extends num> {} |
| 648 final x = new C<D>(); | 679 final x = new C<D>(); |
| 649 '''); | 680 '''); |
| 650 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 681 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 651 library.libraryCycleForLink.ensureLinked(); | 682 library.libraryCycleForLink.ensureLinked(); |
| 652 PropertyAccessorElementForLink_Variable x = library.getContainedName('x'); | 683 PropertyAccessorElementForLink_Variable x = library.getContainedName('x'); |
| 653 ParameterizedType type1 = x.returnType; | 684 ParameterizedType type1 = x.returnType; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 */ | 991 */ |
| 961 EntityRef _lookupInferredType(LinkedUnit unit, int slot) { | 992 EntityRef _lookupInferredType(LinkedUnit unit, int slot) { |
| 962 for (EntityRef ref in unit.types) { | 993 for (EntityRef ref in unit.types) { |
| 963 if (ref.slot == slot) { | 994 if (ref.slot == slot) { |
| 964 return ref; | 995 return ref; |
| 965 } | 996 } |
| 966 } | 997 } |
| 967 return null; | 998 return null; |
| 968 } | 999 } |
| 969 } | 1000 } |
| OLD | NEW |