| 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:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 linker | 501 linker |
| 502 .getLibrary(linkerInputs.testDartUri) | 502 .getLibrary(linkerInputs.testDartUri) |
| 503 .getContainedName('b') | 503 .getContainedName('b') |
| 504 .asTypeInferenceNode | 504 .asTypeInferenceNode |
| 505 .variableElement | 505 .variableElement |
| 506 .inferredType | 506 .inferredType |
| 507 .toString(), | 507 .toString(), |
| 508 'int'); | 508 'int'); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void test_instantiate_param_of_param_to_bounds() { |
| 512 createLinker(''' |
| 513 class C<T> {} |
| 514 class D<T extends num> {} |
| 515 final x = new C<D>(); |
| 516 '''); |
| 517 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 518 library.libraryCycleForLink.ensureLinked(); |
| 519 PropertyAccessorElementForLink_Variable x = library.getContainedName('x'); |
| 520 ParameterizedType type1 = x.returnType; |
| 521 expect(type1.element.name, 'C'); |
| 522 expect(type1.typeArguments, hasLength(1)); |
| 523 ParameterizedType type2 = type1.typeArguments[0]; |
| 524 expect(type2.element.name, 'D'); |
| 525 expect(type2.typeArguments, hasLength(1)); |
| 526 DartType type3 = type2.typeArguments[0]; |
| 527 expect(type3.toString(), 'num'); |
| 528 } |
| 529 |
| 530 void test_instantiate_param_to_bounds_class() { |
| 531 createLinker(''' |
| 532 class C<T extends num> {} |
| 533 final x = new C(); |
| 534 '''); |
| 535 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 536 library.libraryCycleForLink.ensureLinked(); |
| 537 PropertyAccessorElementForLink_Variable x = library.getContainedName('x'); |
| 538 ParameterizedType type1 = x.returnType; |
| 539 expect(type1.element.name, 'C'); |
| 540 expect(type1.typeArguments, hasLength(1)); |
| 541 DartType type2 = type1.typeArguments[0]; |
| 542 expect(type2.toString(), 'num'); |
| 543 } |
| 544 |
| 545 void test_instantiate_param_to_bounds_typedef() { |
| 546 createLinker(''' |
| 547 typedef T F<T extends num>(); |
| 548 final x = new List<F>(); |
| 549 '''); |
| 550 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 551 library.libraryCycleForLink.ensureLinked(); |
| 552 PropertyAccessorElementForLink_Variable x = library.getContainedName('x'); |
| 553 ParameterizedType type1 = x.returnType; |
| 554 expect(type1.element.name, 'List'); |
| 555 expect(type1.typeArguments, hasLength(1)); |
| 556 FunctionType type2 = type1.typeArguments[0]; |
| 557 expect(type2.element.name, 'F'); |
| 558 expect(type2.returnType.toString(), 'num'); |
| 559 } |
| 560 |
| 511 void test_leastUpperBound_functionAndClass() { | 561 void test_leastUpperBound_functionAndClass() { |
| 512 createLinker(''' | 562 createLinker(''' |
| 513 class C {} | 563 class C {} |
| 514 void f() {} | 564 void f() {} |
| 515 var x = { | 565 var x = { |
| 516 'C': C, | 566 'C': C, |
| 517 'f': f | 567 'f': f |
| 518 }; | 568 }; |
| 519 '''); | 569 '''); |
| 520 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 570 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 PropertyAccessorElementForLink_Variable c = library.getContainedName('c'); | 817 PropertyAccessorElementForLink_Variable c = library.getContainedName('c'); |
| 768 expect(c.variable.initializer, isNotNull); | 818 expect(c.variable.initializer, isNotNull); |
| 769 PropertyAccessorElementForLink_Variable i = library.getContainedName('i'); | 819 PropertyAccessorElementForLink_Variable i = library.getContainedName('i'); |
| 770 expect(i.variable.initializer, isNotNull); | 820 expect(i.variable.initializer, isNotNull); |
| 771 PropertyAccessorElementForLink_Variable j = library.getContainedName('j'); | 821 PropertyAccessorElementForLink_Variable j = library.getContainedName('j'); |
| 772 expect(j.variable.initializer, isNull); | 822 expect(j.variable.initializer, isNull); |
| 773 PropertyAccessorElementForLink_Variable v = library.getContainedName('v'); | 823 PropertyAccessorElementForLink_Variable v = library.getContainedName('v'); |
| 774 expect(v.variable.initializer, isNotNull); | 824 expect(v.variable.initializer, isNotNull); |
| 775 } | 825 } |
| 776 } | 826 } |
| OLD | NEW |