| 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/summary/format.dart'; | 7 import 'package:analyzer/src/summary/format.dart'; |
| 7 import 'package:analyzer/src/summary/link.dart'; | 8 import 'package:analyzer/src/summary/link.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 9 | 10 |
| 10 import '../../reflective_tests.dart'; | 11 import '../../reflective_tests.dart'; |
| 11 import 'summarize_ast_test.dart'; | 12 import 'summarize_ast_test.dart'; |
| 12 | 13 |
| 13 main() { | 14 main() { |
| 14 groupSep = ' | '; | 15 groupSep = ' | '; |
| 15 runReflectiveTests(LinkerUnitTest); | 16 runReflectiveTests(LinkerUnitTest); |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 expect(gTypeElement.typeParameterContext, same(f)); | 595 expect(gTypeElement.typeParameterContext, same(f)); |
| 595 ParameterElementForLink h = gTypeElement.parameters[0]; | 596 ParameterElementForLink h = gTypeElement.parameters[0]; |
| 596 FunctionType hType = h.type; | 597 FunctionType hType = h.type; |
| 597 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element; | 598 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element; |
| 598 expect(hTypeElement.typeParameterContext, same(f)); | 599 expect(hTypeElement.typeParameterContext, same(f)); |
| 599 } | 600 } |
| 600 | 601 |
| 601 void test_typeParameter_isTypeParameterInScope_direct() { | 602 void test_typeParameter_isTypeParameterInScope_direct() { |
| 602 createLinker('class C<T, U> {}'); | 603 createLinker('class C<T, U> {}'); |
| 603 ClassElementForLink_Class c = testLibrary.getContainedName('C'); | 604 ClassElementForLink_Class c = testLibrary.getContainedName('C'); |
| 604 TypeParameterElementForLink t = c.typeParameters[0]; | 605 TypeParameterElementImpl t = c.typeParameters[0]; |
| 605 TypeParameterElementForLink u = c.typeParameters[1]; | 606 TypeParameterElementImpl u = c.typeParameters[1]; |
| 606 expect(c.isTypeParameterInScope(t), true); | 607 expect(c.isTypeParameterInScope(t), true); |
| 607 expect(c.isTypeParameterInScope(u), true); | 608 expect(c.isTypeParameterInScope(u), true); |
| 608 } | 609 } |
| 609 | 610 |
| 610 void test_typeParameter_isTypeParameterInScope_indirect() { | 611 void test_typeParameter_isTypeParameterInScope_indirect() { |
| 611 createLinker('class C<T, U> { f<V, W>() {} }'); | 612 createLinker('class C<T, U> { f<V, W>() {} }'); |
| 612 ClassElementForLink_Class c = testLibrary.getContainedName('C'); | 613 ClassElementForLink_Class c = testLibrary.getContainedName('C'); |
| 613 MethodElementForLink f = c.methods[0]; | 614 MethodElementForLink f = c.methods[0]; |
| 614 TypeParameterElementForLink t = c.typeParameters[0]; | 615 TypeParameterElementImpl t = c.typeParameters[0]; |
| 615 TypeParameterElementForLink u = c.typeParameters[1]; | 616 TypeParameterElementImpl u = c.typeParameters[1]; |
| 616 expect(f.isTypeParameterInScope(t), true); | 617 expect(f.isTypeParameterInScope(t), true); |
| 617 expect(f.isTypeParameterInScope(u), true); | 618 expect(f.isTypeParameterInScope(u), true); |
| 618 } | 619 } |
| 619 | 620 |
| 620 void test_typeParameter_isTypeParameterInScope_reversed() { | 621 void test_typeParameter_isTypeParameterInScope_reversed() { |
| 621 createLinker('class C<T, U> { f<V, W>() {} }'); | 622 createLinker('class C<T, U> { f<V, W>() {} }'); |
| 622 ClassElementForLink_Class c = testLibrary.getContainedName('C'); | 623 ClassElementForLink_Class c = testLibrary.getContainedName('C'); |
| 623 MethodElementForLink f = c.methods[0]; | 624 MethodElementForLink f = c.methods[0]; |
| 624 TypeParameterElementForLink v = f.typeParameters[0]; | 625 TypeParameterElementImpl v = f.typeParameters[0]; |
| 625 TypeParameterElementForLink w = f.typeParameters[1]; | 626 TypeParameterElementImpl w = f.typeParameters[1]; |
| 626 expect(c.isTypeParameterInScope(v), false); | 627 expect(c.isTypeParameterInScope(v), false); |
| 627 expect(c.isTypeParameterInScope(w), false); | 628 expect(c.isTypeParameterInScope(w), false); |
| 628 } | 629 } |
| 629 | 630 |
| 630 void test_typeParameter_isTypeParameterInScope_unrelated() { | 631 void test_typeParameter_isTypeParameterInScope_unrelated() { |
| 631 createLinker('class C<T, U> {} class D<V, W> {}'); | 632 createLinker('class C<T, U> {} class D<V, W> {}'); |
| 632 ClassElementForLink_Class c = testLibrary.getContainedName('C'); | 633 ClassElementForLink_Class c = testLibrary.getContainedName('C'); |
| 633 ClassElementForLink_Class d = testLibrary.getContainedName('D'); | 634 ClassElementForLink_Class d = testLibrary.getContainedName('D'); |
| 634 TypeParameterElementForLink t = c.typeParameters[0]; | 635 TypeParameterElementImpl t = c.typeParameters[0]; |
| 635 TypeParameterElementForLink u = c.typeParameters[1]; | 636 TypeParameterElementImpl u = c.typeParameters[1]; |
| 636 TypeParameterElementForLink v = d.typeParameters[0]; | 637 TypeParameterElementImpl v = d.typeParameters[0]; |
| 637 TypeParameterElementForLink w = d.typeParameters[1]; | 638 TypeParameterElementImpl w = d.typeParameters[1]; |
| 638 expect(c.isTypeParameterInScope(v), false); | 639 expect(c.isTypeParameterInScope(v), false); |
| 639 expect(c.isTypeParameterInScope(w), false); | 640 expect(c.isTypeParameterInScope(w), false); |
| 640 expect(d.isTypeParameterInScope(t), false); | 641 expect(d.isTypeParameterInScope(t), false); |
| 641 expect(d.isTypeParameterInScope(u), false); | 642 expect(d.isTypeParameterInScope(u), false); |
| 642 } | 643 } |
| 643 } | 644 } |
| OLD | NEW |