OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.src.task.strong_mode_test; | 5 library test.src.task.strong_mode_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
10 import 'package:analyzer/src/task/strong_mode.dart'; | 10 import 'package:analyzer/src/task/strong_mode.dart'; |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 String methodName = 'm'; | 700 String methodName = 'm'; |
701 CompilationUnitElement unit = resolve(''' | 701 CompilationUnitElement unit = resolve(''' |
702 class A<E> { | 702 class A<E> { |
703 $methodName(E p) => 0; | 703 $methodName(E p) => 0; |
704 } | 704 } |
705 class C<E> implements A<E> { | 705 class C<E> implements A<E> { |
706 $methodName(p) => 0; | 706 $methodName(p) => 0; |
707 } | 707 } |
708 '''); | 708 '''); |
709 ClassElement classC = unit.getType('C'); | 709 ClassElement classC = unit.getType('C'); |
710 DartType typeCE = classC.typeParameters[0].type; | |
710 MethodElement methodC = classC.getMethod(methodName); | 711 MethodElement methodC = classC.getMethod(methodName); |
711 ParameterElement parameterC = methodC.parameters[0]; | 712 ParameterElement parameterC = methodC.parameters[0]; |
712 expect(parameterC.type.isDynamic, isTrue); | 713 expect(parameterC.type.isDynamic, isTrue); |
714 expect(methodC.type.typeArguments, [typeCE]); | |
713 | 715 |
714 inferrer.inferCompilationUnit(unit); | 716 inferrer.inferCompilationUnit(unit); |
715 | 717 |
716 expect(parameterC.type, classC.typeParameters[0].type); | 718 expect(parameterC.type, classC.typeParameters[0].type); |
719 expect(methodC.type.typeArguments, [typeCE], | |
Jennifer Messerly
2015/09/24 22:35:56
this check was failing without the fix.
| |
720 reason: 'function type should still have type arguments'); | |
717 } | 721 } |
718 | 722 |
719 void test_inferCompilationUnit_method_return_multiple_different() { | 723 void test_inferCompilationUnit_method_return_multiple_different() { |
720 InstanceMemberInferrer inferrer = createInferrer; | 724 InstanceMemberInferrer inferrer = createInferrer; |
721 String methodName = 'm'; | 725 String methodName = 'm'; |
722 CompilationUnitElement unit = resolve(''' | 726 CompilationUnitElement unit = resolve(''' |
723 class A { | 727 class A { |
724 int $methodName() => 0; | 728 int $methodName() => 0; |
725 } | 729 } |
726 class B { | 730 class B { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
910 String methodName = 'm'; | 914 String methodName = 'm'; |
911 CompilationUnitElement unit = resolve(''' | 915 CompilationUnitElement unit = resolve(''' |
912 class A<E> { | 916 class A<E> { |
913 E $methodName() => 0; | 917 E $methodName() => 0; |
914 } | 918 } |
915 class B<E> extends A<E> { | 919 class B<E> extends A<E> { |
916 $methodName() => 0; | 920 $methodName() => 0; |
917 } | 921 } |
918 '''); | 922 '''); |
919 ClassElement classB = unit.getType('B'); | 923 ClassElement classB = unit.getType('B'); |
924 DartType typeBE = classB.typeParameters[0].type; | |
920 MethodElement methodB = classB.getMethod(methodName); | 925 MethodElement methodB = classB.getMethod(methodName); |
921 expect(methodB.returnType.isDynamic, isTrue); | 926 expect(methodB.returnType.isDynamic, isTrue); |
927 expect(methodB.type.typeArguments, [typeBE]); | |
922 | 928 |
923 inferrer.inferCompilationUnit(unit); | 929 inferrer.inferCompilationUnit(unit); |
924 | 930 |
925 expect(methodB.returnType, classB.typeParameters[0].type); | 931 expect(methodB.returnType, classB.typeParameters[0].type); |
932 expect(methodB.type.typeArguments, [typeBE], | |
933 reason: 'function type should still have type arguments'); | |
926 } | 934 } |
927 } | 935 } |
928 | 936 |
929 @reflectiveTest | 937 @reflectiveTest |
930 class VariableGathererTest extends AbstractContextTest { | 938 class VariableGathererTest extends AbstractContextTest { |
931 void test_creation_withFilter() { | 939 void test_creation_withFilter() { |
932 VariableFilter filter = (variable) => true; | 940 VariableFilter filter = (variable) => true; |
933 VariableGatherer gatherer = new VariableGatherer(filter); | 941 VariableGatherer gatherer = new VariableGatherer(filter); |
934 expect(gatherer, isNotNull); | 942 expect(gatherer, isNotNull); |
935 expect(gatherer.filter, filter); | 943 expect(gatherer.filter, filter); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 } | 995 } |
988 } | 996 } |
989 } | 997 } |
990 '''); | 998 '''); |
991 CompilationUnit unit = context.resolveCompilationUnit2(source, source); | 999 CompilationUnit unit = context.resolveCompilationUnit2(source, source); |
992 VariableGatherer gatherer = new VariableGatherer(filter); | 1000 VariableGatherer gatherer = new VariableGatherer(filter); |
993 unit.accept(gatherer); | 1001 unit.accept(gatherer); |
994 return gatherer.results; | 1002 return gatherer.results; |
995 } | 1003 } |
996 } | 1004 } |
OLD | NEW |