| 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/src/summary/format.dart'; | 6 import 'package:analyzer/src/summary/format.dart'; |
| 6 import 'package:analyzer/src/summary/link.dart'; | 7 import 'package:analyzer/src/summary/link.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 8 | 9 |
| 9 import '../../reflective_tests.dart'; | 10 import '../../reflective_tests.dart'; |
| 10 import 'summarize_ast_test.dart'; | 11 import 'summarize_ast_test.dart'; |
| 11 | 12 |
| 12 main() { | 13 main() { |
| 13 groupSep = ' | '; | 14 groupSep = ' | '; |
| 14 runReflectiveTests(LinkerUnitTest); | 15 runReflectiveTests(LinkerUnitTest); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 60 } |
| 60 class C<T> extends B<T> { | 61 class C<T> extends B<T> { |
| 61 void f() {} | 62 void f() {} |
| 62 } | 63 } |
| 63 '''); | 64 '''); |
| 64 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 65 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 65 library.libraryCycleForLink.ensureLinked(); | 66 library.libraryCycleForLink.ensureLinked(); |
| 66 // No assertions--just make sure it doesn't crash. | 67 // No assertions--just make sure it doesn't crash. |
| 67 } | 68 } |
| 68 | 69 |
| 70 void test_baseClass_genericWithFunctionTypedParameter() { |
| 71 createLinker(''' |
| 72 class B<T> { |
| 73 void f(void g(T t)); |
| 74 } |
| 75 class C<U> extends B<U> { |
| 76 void f(g) {} |
| 77 } |
| 78 '''); |
| 79 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 80 library.libraryCycleForLink.ensureLinked(); |
| 81 // No assertions--just make sure it doesn't crash. |
| 82 } |
| 83 |
| 69 void test_baseClass_genericWithGenericMethod() { | 84 void test_baseClass_genericWithGenericMethod() { |
| 70 createLinker(''' | 85 createLinker(''' |
| 71 class B<T> { | 86 class B<T> { |
| 72 List<U> f<U>(U u) => null; | 87 List<U> f<U>(U u) => null; |
| 73 } | 88 } |
| 74 class C<V> extends B<V> { | 89 class C<V> extends B<V> { |
| 75 var j; | 90 var j; |
| 76 } | 91 } |
| 77 '''); | 92 '''); |
| 78 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 93 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 548 } |
| 534 class C extends B with I {} | 549 class C extends B with I {} |
| 535 class D extends C { | 550 class D extends C { |
| 536 void f() {} | 551 void f() {} |
| 537 } | 552 } |
| 538 '''); | 553 '''); |
| 539 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); | 554 LibraryElementForLink library = linker.getLibrary(linkerInputs.testDartUri); |
| 540 library.libraryCycleForLink.ensureLinked(); | 555 library.libraryCycleForLink.ensureLinked(); |
| 541 // No assertions--just make sure it doesn't crash. | 556 // No assertions--just make sure it doesn't crash. |
| 542 } | 557 } |
| 558 |
| 559 void test_parameterParentElementForLink_implicitFunctionTypeIndices() { |
| 560 createLinker('void f(a, void g(b, c, d, void h())) {}'); |
| 561 TopLevelFunctionElementForLink f = testLibrary.getContainedName('f'); |
| 562 expect(f.implicitFunctionTypeIndices, []); |
| 563 ParameterElementForLink g = f.parameters[1]; |
| 564 FunctionType gType = g.type; |
| 565 FunctionElementForLink_FunctionTypedParam gTypeElement = gType.element; |
| 566 expect(gTypeElement.implicitFunctionTypeIndices, [1]); |
| 567 ParameterElementForLink h = gTypeElement.parameters[3]; |
| 568 FunctionType hType = h.type; |
| 569 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element; |
| 570 expect(hTypeElement.implicitFunctionTypeIndices, [1, 3]); |
| 571 } |
| 572 |
| 573 void test_parameterParentElementForLink_innermostExecutable() { |
| 574 createLinker('void f(void g(void h())) {}'); |
| 575 TopLevelFunctionElementForLink f = testLibrary.getContainedName('f'); |
| 576 expect(f.innermostExecutable, same(f)); |
| 577 ParameterElementForLink g = f.parameters[0]; |
| 578 FunctionType gType = g.type; |
| 579 FunctionElementForLink_FunctionTypedParam gTypeElement = gType.element; |
| 580 expect(gTypeElement.innermostExecutable, same(f)); |
| 581 ParameterElementForLink h = gTypeElement.parameters[0]; |
| 582 FunctionType hType = h.type; |
| 583 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element; |
| 584 expect(hTypeElement.innermostExecutable, same(f)); |
| 585 } |
| 543 } | 586 } |
| OLD | NEW |