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 analyzer.test.src.task.dart_test; | 5 library analyzer.test.src.task.dart_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 runReflectiveTests(BuildExportNamespaceTaskTest); | 42 runReflectiveTests(BuildExportNamespaceTaskTest); |
43 runReflectiveTests(BuildLibraryElementTaskTest); | 43 runReflectiveTests(BuildLibraryElementTaskTest); |
44 runReflectiveTests(BuildPublicNamespaceTaskTest); | 44 runReflectiveTests(BuildPublicNamespaceTaskTest); |
45 runReflectiveTests(BuildSourceExportClosureTaskTest); | 45 runReflectiveTests(BuildSourceExportClosureTaskTest); |
46 runReflectiveTests(BuildTypeProviderTaskTest); | 46 runReflectiveTests(BuildTypeProviderTaskTest); |
47 runReflectiveTests(BuildTypeProviderTaskTest_noAsync); | 47 runReflectiveTests(BuildTypeProviderTaskTest_noAsync); |
48 runReflectiveTests(ComputeConstantDependenciesTaskTest); | 48 runReflectiveTests(ComputeConstantDependenciesTaskTest); |
49 runReflectiveTests(ComputeConstantValueTaskTest); | 49 runReflectiveTests(ComputeConstantValueTaskTest); |
50 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest); | 50 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest); |
51 runReflectiveTests(ComputeLibraryCycleTaskTest); | 51 runReflectiveTests(ComputeLibraryCycleTaskTest); |
52 runReflectiveTests(ComputePropagableVariableDependenciesTaskTest); | |
53 runReflectiveTests(ContainingLibrariesTaskTest); | 52 runReflectiveTests(ContainingLibrariesTaskTest); |
54 runReflectiveTests(DartErrorsTaskTest); | 53 runReflectiveTests(DartErrorsTaskTest); |
55 runReflectiveTests(EvaluateUnitConstantsTaskTest); | 54 runReflectiveTests(EvaluateUnitConstantsTaskTest); |
56 runReflectiveTests(GatherUsedImportedElementsTaskTest); | 55 runReflectiveTests(GatherUsedImportedElementsTaskTest); |
57 runReflectiveTests(GatherUsedLocalElementsTaskTest); | 56 runReflectiveTests(GatherUsedLocalElementsTaskTest); |
58 runReflectiveTests(GenerateHintsTaskTest); | 57 runReflectiveTests(GenerateHintsTaskTest); |
59 runReflectiveTests(GenerateLintsTaskTest); | 58 runReflectiveTests(GenerateLintsTaskTest); |
60 runReflectiveTests(InferInstanceMembersInUnitTaskTest); | 59 runReflectiveTests(InferInstanceMembersInUnitTaskTest); |
61 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest); | 60 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest); |
62 runReflectiveTests(InferStaticVariableTypeTaskTest); | 61 runReflectiveTests(InferStaticVariableTypeTaskTest); |
63 runReflectiveTests(LibraryErrorsReadyTaskTest); | 62 runReflectiveTests(LibraryErrorsReadyTaskTest); |
64 runReflectiveTests(LibraryUnitErrorsTaskTest); | 63 runReflectiveTests(LibraryUnitErrorsTaskTest); |
65 runReflectiveTests(ParseDartTaskTest); | 64 runReflectiveTests(ParseDartTaskTest); |
66 runReflectiveTests(PartiallyResolveUnitReferencesTaskTest); | 65 runReflectiveTests(PartiallyResolveUnitReferencesTaskTest); |
67 runReflectiveTests(PropagateVariableTypesInUnitTaskTest); | |
68 runReflectiveTests(PropagateVariableTypeTaskTest); | |
69 runReflectiveTests(ReferencedNamesBuilderTest); | 66 runReflectiveTests(ReferencedNamesBuilderTest); |
70 runReflectiveTests(ResolveDirectiveElementsTaskTest); | 67 runReflectiveTests(ResolveDirectiveElementsTaskTest); |
71 runReflectiveTests(ResolveInstanceFieldsInUnitTaskTest); | 68 runReflectiveTests(ResolveInstanceFieldsInUnitTaskTest); |
72 runReflectiveTests(ResolveLibraryTaskTest); | 69 runReflectiveTests(ResolveLibraryTaskTest); |
73 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); | 70 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); |
74 runReflectiveTests(ResolveTopLevelUnitTypeBoundsTaskTest); | 71 runReflectiveTests(ResolveTopLevelUnitTypeBoundsTaskTest); |
75 runReflectiveTests(ResolveUnitTaskTest); | 72 runReflectiveTests(ResolveUnitTaskTest); |
76 runReflectiveTests(ResolveUnitTypeNamesTaskTest); | 73 runReflectiveTests(ResolveUnitTypeNamesTaskTest); |
77 runReflectiveTests(ResolveVariableReferencesTaskTest); | 74 runReflectiveTests(ResolveVariableReferencesTaskTest); |
78 runReflectiveTests(ScanDartTaskTest); | 75 runReflectiveTests(ScanDartTaskTest); |
(...skipping 17 matching lines...) Expand all Loading... |
96 isInstanceOf isBuildSourceExportClosureTask = | 93 isInstanceOf isBuildSourceExportClosureTask = |
97 new isInstanceOf<BuildSourceExportClosureTask>(); | 94 new isInstanceOf<BuildSourceExportClosureTask>(); |
98 isInstanceOf isBuildTypeProviderTask = | 95 isInstanceOf isBuildTypeProviderTask = |
99 new isInstanceOf<BuildTypeProviderTask>(); | 96 new isInstanceOf<BuildTypeProviderTask>(); |
100 isInstanceOf isComputeConstantDependenciesTask = | 97 isInstanceOf isComputeConstantDependenciesTask = |
101 new isInstanceOf<ComputeConstantDependenciesTask>(); | 98 new isInstanceOf<ComputeConstantDependenciesTask>(); |
102 isInstanceOf isComputeConstantValueTask = | 99 isInstanceOf isComputeConstantValueTask = |
103 new isInstanceOf<ComputeConstantValueTask>(); | 100 new isInstanceOf<ComputeConstantValueTask>(); |
104 isInstanceOf isComputeInferableStaticVariableDependenciesTask = | 101 isInstanceOf isComputeInferableStaticVariableDependenciesTask = |
105 new isInstanceOf<ComputeInferableStaticVariableDependenciesTask>(); | 102 new isInstanceOf<ComputeInferableStaticVariableDependenciesTask>(); |
106 isInstanceOf isComputePropagableVariableDependenciesTask = | |
107 new isInstanceOf<ComputePropagableVariableDependenciesTask>(); | |
108 isInstanceOf isContainingLibrariesTask = | 103 isInstanceOf isContainingLibrariesTask = |
109 new isInstanceOf<ContainingLibrariesTask>(); | 104 new isInstanceOf<ContainingLibrariesTask>(); |
110 isInstanceOf isDartErrorsTask = new isInstanceOf<DartErrorsTask>(); | 105 isInstanceOf isDartErrorsTask = new isInstanceOf<DartErrorsTask>(); |
111 isInstanceOf isEvaluateUnitConstantsTask = | 106 isInstanceOf isEvaluateUnitConstantsTask = |
112 new isInstanceOf<EvaluateUnitConstantsTask>(); | 107 new isInstanceOf<EvaluateUnitConstantsTask>(); |
113 isInstanceOf isGatherUsedImportedElementsTask = | 108 isInstanceOf isGatherUsedImportedElementsTask = |
114 new isInstanceOf<GatherUsedImportedElementsTask>(); | 109 new isInstanceOf<GatherUsedImportedElementsTask>(); |
115 isInstanceOf isGatherUsedLocalElementsTask = | 110 isInstanceOf isGatherUsedLocalElementsTask = |
116 new isInstanceOf<GatherUsedLocalElementsTask>(); | 111 new isInstanceOf<GatherUsedLocalElementsTask>(); |
117 isInstanceOf isGenerateHintsTask = new isInstanceOf<GenerateHintsTask>(); | 112 isInstanceOf isGenerateHintsTask = new isInstanceOf<GenerateHintsTask>(); |
118 isInstanceOf isGenerateLintsTask = new isInstanceOf<GenerateLintsTask>(); | 113 isInstanceOf isGenerateLintsTask = new isInstanceOf<GenerateLintsTask>(); |
119 isInstanceOf isInferInstanceMembersInUnitTask = | 114 isInstanceOf isInferInstanceMembersInUnitTask = |
120 new isInstanceOf<InferInstanceMembersInUnitTask>(); | 115 new isInstanceOf<InferInstanceMembersInUnitTask>(); |
121 isInstanceOf isInferStaticVariableTypesInUnitTask = | 116 isInstanceOf isInferStaticVariableTypesInUnitTask = |
122 new isInstanceOf<InferStaticVariableTypesInUnitTask>(); | 117 new isInstanceOf<InferStaticVariableTypesInUnitTask>(); |
123 isInstanceOf isInferStaticVariableTypeTask = | 118 isInstanceOf isInferStaticVariableTypeTask = |
124 new isInstanceOf<InferStaticVariableTypeTask>(); | 119 new isInstanceOf<InferStaticVariableTypeTask>(); |
125 isInstanceOf isLibraryErrorsReadyTask = | 120 isInstanceOf isLibraryErrorsReadyTask = |
126 new isInstanceOf<LibraryErrorsReadyTask>(); | 121 new isInstanceOf<LibraryErrorsReadyTask>(); |
127 isInstanceOf isLibraryUnitErrorsTask = | 122 isInstanceOf isLibraryUnitErrorsTask = |
128 new isInstanceOf<LibraryUnitErrorsTask>(); | 123 new isInstanceOf<LibraryUnitErrorsTask>(); |
129 isInstanceOf isParseDartTask = new isInstanceOf<ParseDartTask>(); | 124 isInstanceOf isParseDartTask = new isInstanceOf<ParseDartTask>(); |
130 isInstanceOf isPartiallyResolveUnitReferencesTask = | 125 isInstanceOf isPartiallyResolveUnitReferencesTask = |
131 new isInstanceOf<PartiallyResolveUnitReferencesTask>(); | 126 new isInstanceOf<PartiallyResolveUnitReferencesTask>(); |
132 isInstanceOf isPropagateVariableTypesInUnitTask = | |
133 new isInstanceOf<PropagateVariableTypesInUnitTask>(); | |
134 isInstanceOf isPropagateVariableTypeTask = | |
135 new isInstanceOf<PropagateVariableTypeTask>(); | |
136 isInstanceOf isResolveDirectiveElementsTask = | 127 isInstanceOf isResolveDirectiveElementsTask = |
137 new isInstanceOf<ResolveDirectiveElementsTask>(); | 128 new isInstanceOf<ResolveDirectiveElementsTask>(); |
138 isInstanceOf isResolveLibraryReferencesTask = | 129 isInstanceOf isResolveLibraryReferencesTask = |
139 new isInstanceOf<ResolveLibraryReferencesTask>(); | 130 new isInstanceOf<ResolveLibraryReferencesTask>(); |
140 isInstanceOf isResolveLibraryTask = new isInstanceOf<ResolveLibraryTask>(); | 131 isInstanceOf isResolveLibraryTask = new isInstanceOf<ResolveLibraryTask>(); |
141 isInstanceOf isResolveLibraryTypeNamesTask = | 132 isInstanceOf isResolveLibraryTypeNamesTask = |
142 new isInstanceOf<ResolveLibraryTypeNamesTask>(); | 133 new isInstanceOf<ResolveLibraryTypeNamesTask>(); |
143 isInstanceOf isResolveTopLevelUnitTypeBoundsTask = | 134 isInstanceOf isResolveTopLevelUnitTypeBoundsTask = |
144 new isInstanceOf<ResolveTopLevelUnitTypeBoundsTask>(); | 135 new isInstanceOf<ResolveTopLevelUnitTypeBoundsTask>(); |
145 isInstanceOf isResolveUnitTask = new isInstanceOf<ResolveUnitTask>(); | 136 isInstanceOf isResolveUnitTask = new isInstanceOf<ResolveUnitTask>(); |
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 expect(cycle.map((e) => e.source), unorderedEquals(expected)); | 2001 expect(cycle.map((e) => e.source), unorderedEquals(expected)); |
2011 } | 2002 } |
2012 | 2003 |
2013 void _expectInvalid(Source librarySource) { | 2004 void _expectInvalid(Source librarySource) { |
2014 CacheEntry entry = context.getCacheEntry(librarySource); | 2005 CacheEntry entry = context.getCacheEntry(librarySource); |
2015 expect(entry.getState(LIBRARY_CYCLE), CacheState.INVALID); | 2006 expect(entry.getState(LIBRARY_CYCLE), CacheState.INVALID); |
2016 } | 2007 } |
2017 } | 2008 } |
2018 | 2009 |
2019 @reflectiveTest | 2010 @reflectiveTest |
2020 class ComputePropagableVariableDependenciesTaskTest | |
2021 extends _AbstractDartTaskTest { | |
2022 List<VariableElement> getPropagableVariableDependencies( | |
2023 Map<ResultDescriptor, dynamic> outputs) { | |
2024 return outputs[PROPAGABLE_VARIABLE_DEPENDENCIES] as List<VariableElement>; | |
2025 } | |
2026 | |
2027 test_perform_instanceField() { | |
2028 AnalysisTarget source = newSource( | |
2029 '/test.dart', | |
2030 ''' | |
2031 class A { | |
2032 final a = a1 + a2 + a3 + a4 + B.b1 + B.b2 + B.b3 + B.b4; | |
2033 static const a1 = 1; | |
2034 final a2 = 2; | |
2035 final a3; | |
2036 var a4 = 4; | |
2037 } | |
2038 class B { | |
2039 static const b1 = 1; | |
2040 static final b2 = 2; | |
2041 static final b3; | |
2042 static var b4 = 4; | |
2043 } | |
2044 '''); | |
2045 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
2046 computeResult(target, RESOLVED_UNIT7); | |
2047 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
2048 FieldElement elementA = AstFinder.getFieldInClassElement(unit, 'A', 'a'); | |
2049 // compute | |
2050 computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES, | |
2051 matcher: isComputePropagableVariableDependenciesTask); | |
2052 // verify | |
2053 expect(outputs, hasLength(1)); | |
2054 List<VariableElement> dependencies = | |
2055 getPropagableVariableDependencies(outputs); | |
2056 expect( | |
2057 dependencies, | |
2058 unorderedEquals([ | |
2059 AstFinder.getFieldInClassElement(unit, 'A', 'a1'), | |
2060 AstFinder.getFieldInClassElement(unit, 'A', 'a2'), | |
2061 AstFinder.getFieldInClassElement(unit, 'B', 'b1'), | |
2062 AstFinder.getFieldInClassElement(unit, 'B', 'b2') | |
2063 ])); | |
2064 } | |
2065 | |
2066 test_perform_topLevel() { | |
2067 AnalysisTarget source = newSource( | |
2068 '/test.dart', | |
2069 ''' | |
2070 const a = d1 + d2 + d3 + d4; | |
2071 const d1 = 1; | |
2072 final d2 = 2; | |
2073 final d3; | |
2074 var d4 = 4; | |
2075 '''); | |
2076 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
2077 computeResult(target, RESOLVED_UNIT7); | |
2078 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
2079 TopLevelVariableElement elementA = | |
2080 AstFinder.getTopLevelVariableElement(unit, 'a'); | |
2081 // compute | |
2082 computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES, | |
2083 matcher: isComputePropagableVariableDependenciesTask); | |
2084 // verify | |
2085 expect(outputs, hasLength(1)); | |
2086 List<VariableElement> dependencies = | |
2087 getPropagableVariableDependencies(outputs); | |
2088 expect( | |
2089 dependencies, | |
2090 unorderedEquals([ | |
2091 AstFinder.getTopLevelVariableElement(unit, 'd1'), | |
2092 AstFinder.getTopLevelVariableElement(unit, 'd2') | |
2093 ])); | |
2094 } | |
2095 | |
2096 test_perform_topLevel_ignoreLocal() { | |
2097 AnalysisTarget source = newSource( | |
2098 '/test.dart', | |
2099 ''' | |
2100 final a = () { | |
2101 const b = 2; | |
2102 const c = 3; | |
2103 return b + c; | |
2104 }() + d; | |
2105 final d = 4; | |
2106 '''); | |
2107 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
2108 computeResult(target, RESOLVED_UNIT7); | |
2109 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
2110 TopLevelVariableElement elementA = | |
2111 AstFinder.getTopLevelVariableElement(unit, 'a'); | |
2112 // compute | |
2113 computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES, | |
2114 matcher: isComputePropagableVariableDependenciesTask); | |
2115 // verify | |
2116 expect(outputs, hasLength(1)); | |
2117 List<VariableElement> dependencies = | |
2118 getPropagableVariableDependencies(outputs); | |
2119 expect(dependencies, | |
2120 unorderedEquals([AstFinder.getTopLevelVariableElement(unit, 'd')])); | |
2121 } | |
2122 | |
2123 test_perform_topLevel_withoutSpaceAfterType() { | |
2124 AnalysisTarget source = newSource( | |
2125 '/test.dart', | |
2126 ''' | |
2127 const List<int>a=[b, c]; | |
2128 const b = 1; | |
2129 const c = 2; | |
2130 '''); | |
2131 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
2132 computeResult(target, RESOLVED_UNIT7); | |
2133 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
2134 TopLevelVariableElement elementA = | |
2135 AstFinder.getTopLevelVariableElement(unit, 'a'); | |
2136 // compute | |
2137 computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES, | |
2138 matcher: isComputePropagableVariableDependenciesTask); | |
2139 // verify | |
2140 expect(outputs, hasLength(1)); | |
2141 List<VariableElement> dependencies = | |
2142 getPropagableVariableDependencies(outputs); | |
2143 expect( | |
2144 dependencies, | |
2145 unorderedEquals([ | |
2146 AstFinder.getTopLevelVariableElement(unit, 'b'), | |
2147 AstFinder.getTopLevelVariableElement(unit, 'c') | |
2148 ])); | |
2149 } | |
2150 } | |
2151 | |
2152 @reflectiveTest | |
2153 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { | 2011 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { |
2154 List<Source> getContainingLibraries(Map<ResultDescriptor, dynamic> outputs) { | 2012 List<Source> getContainingLibraries(Map<ResultDescriptor, dynamic> outputs) { |
2155 return outputs[CONTAINING_LIBRARIES] as List<Source>; | 2013 return outputs[CONTAINING_LIBRARIES] as List<Source>; |
2156 } | 2014 } |
2157 | 2015 |
2158 test_perform_definingCompilationUnit() { | 2016 test_perform_definingCompilationUnit() { |
2159 AnalysisTarget library = newSource('/test.dart', 'library test;'); | 2017 AnalysisTarget library = newSource('/test.dart', 'library test;'); |
2160 computeResult(library, INCLUDED_PARTS); | 2018 computeResult(library, INCLUDED_PARTS); |
2161 computeResult(library, CONTAINING_LIBRARIES, | 2019 computeResult(library, CONTAINING_LIBRARIES, |
2162 matcher: isContainingLibrariesTask); | 2020 matcher: isContainingLibrariesTask); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 @reflectiveTest | 2088 @reflectiveTest |
2231 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { | 2089 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { |
2232 test_created_resolved_unit() { | 2090 test_created_resolved_unit() { |
2233 Source source = newSource( | 2091 Source source = newSource( |
2234 '/test.dart', | 2092 '/test.dart', |
2235 r''' | 2093 r''' |
2236 library lib; | 2094 library lib; |
2237 class A {} | 2095 class A {} |
2238 '''); | 2096 '''); |
2239 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2097 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2240 computeResult(target, RESOLVED_UNIT13); | 2098 computeResult(target, RESOLVED_UNIT12); |
2241 expect(outputs[RESOLVED_UNIT13], isNotNull); | 2099 expect(outputs[RESOLVED_UNIT12], isNotNull); |
2242 expect(outputs[CREATED_RESOLVED_UNIT13], isTrue); | 2100 expect(outputs[CREATED_RESOLVED_UNIT12], isTrue); |
2243 } | 2101 } |
2244 | 2102 |
2245 test_perform() { | 2103 test_perform() { |
2246 Source source = newSource( | 2104 Source source = newSource( |
2247 '/test.dart', | 2105 '/test.dart', |
2248 ''' | 2106 ''' |
2249 class C { | 2107 class C { |
2250 const C(); | 2108 const C(); |
2251 } | 2109 } |
2252 | 2110 |
2253 @x | 2111 @x |
2254 f() {} | 2112 f() {} |
2255 | 2113 |
2256 const x = const C(); | 2114 const x = const C(); |
2257 '''); | 2115 '''); |
2258 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2116 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2259 computeResult(target, RESOLVED_UNIT13, | 2117 computeResult(target, RESOLVED_UNIT12, |
2260 matcher: isEvaluateUnitConstantsTask); | 2118 matcher: isEvaluateUnitConstantsTask); |
2261 CompilationUnit unit = outputs[RESOLVED_UNIT13]; | 2119 CompilationUnit unit = outputs[RESOLVED_UNIT12]; |
2262 CompilationUnitElement unitElement = unit.element; | 2120 CompilationUnitElement unitElement = unit.element; |
2263 expect( | 2121 expect( |
2264 (unitElement.types[0].constructors[0] as ConstructorElementImpl) | 2122 (unitElement.types[0].constructors[0] as ConstructorElementImpl) |
2265 .isCycleFree, | 2123 .isCycleFree, |
2266 isTrue); | 2124 isTrue); |
2267 expect( | 2125 expect( |
2268 (unitElement.functions[0].metadata[0] as ElementAnnotationImpl) | 2126 (unitElement.functions[0].metadata[0] as ElementAnnotationImpl) |
2269 .evaluationResult, | 2127 .evaluationResult, |
2270 isNotNull); | 2128 isNotNull); |
2271 expect( | 2129 expect( |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 @reflectiveTest | 2616 @reflectiveTest |
2759 class InferInstanceMembersInUnitTaskTest extends _AbstractDartTaskTest { | 2617 class InferInstanceMembersInUnitTaskTest extends _AbstractDartTaskTest { |
2760 test_created_resolved_unit() { | 2618 test_created_resolved_unit() { |
2761 Source source = newSource( | 2619 Source source = newSource( |
2762 '/test.dart', | 2620 '/test.dart', |
2763 r''' | 2621 r''' |
2764 library lib; | 2622 library lib; |
2765 class A {} | 2623 class A {} |
2766 '''); | 2624 '''); |
2767 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2625 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2768 computeResult(target, RESOLVED_UNIT11); | 2626 computeResult(target, RESOLVED_UNIT10); |
2769 expect(outputs[RESOLVED_UNIT11], isNotNull); | 2627 expect(outputs[RESOLVED_UNIT10], isNotNull); |
2770 expect(outputs[CREATED_RESOLVED_UNIT11], isTrue); | 2628 expect(outputs[CREATED_RESOLVED_UNIT10], isTrue); |
2771 } | 2629 } |
2772 | 2630 |
2773 void test_perform() { | 2631 void test_perform() { |
2774 enableStrongMode(); | 2632 enableStrongMode(); |
2775 AnalysisTarget source = newSource( | 2633 AnalysisTarget source = newSource( |
2776 '/test.dart', | 2634 '/test.dart', |
2777 ''' | 2635 ''' |
2778 class A { | 2636 class A { |
2779 X f; | 2637 X f; |
2780 Y m(Z x) {} | 2638 Y m(Z x) {} |
2781 } | 2639 } |
2782 class B extends A { | 2640 class B extends A { |
2783 var f; | 2641 var f; |
2784 m(x) {} | 2642 m(x) {} |
2785 } | 2643 } |
2786 class X {} | 2644 class X {} |
2787 class Y {} | 2645 class Y {} |
2788 class Z {} | 2646 class Z {} |
2789 '''); | 2647 '''); |
2790 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11, | 2648 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10, |
2791 matcher: isInferInstanceMembersInUnitTask); | 2649 matcher: isInferInstanceMembersInUnitTask); |
2792 CompilationUnit unit = outputs[RESOLVED_UNIT11]; | 2650 CompilationUnit unit = outputs[RESOLVED_UNIT10]; |
2793 VariableDeclaration field = AstFinder.getFieldInClass(unit, 'B', 'f'); | 2651 VariableDeclaration field = AstFinder.getFieldInClass(unit, 'B', 'f'); |
2794 MethodDeclaration method = AstFinder.getMethodInClass(unit, 'B', 'm'); | 2652 MethodDeclaration method = AstFinder.getMethodInClass(unit, 'B', 'm'); |
2795 DartType typeX = AstFinder.getClass(unit, 'X').element.type; | 2653 DartType typeX = AstFinder.getClass(unit, 'X').element.type; |
2796 DartType typeY = AstFinder.getClass(unit, 'Y').element.type; | 2654 DartType typeY = AstFinder.getClass(unit, 'Y').element.type; |
2797 DartType typeZ = AstFinder.getClass(unit, 'Z').element.type; | 2655 DartType typeZ = AstFinder.getClass(unit, 'Z').element.type; |
2798 | 2656 |
2799 expect(field.element.type, typeX); | 2657 expect(field.element.type, typeX); |
2800 expect(method.element.returnType, typeY); | 2658 expect(method.element.returnType, typeY); |
2801 expect(method.element.parameters[0].type, typeZ); | 2659 expect(method.element.parameters[0].type, typeZ); |
2802 } | 2660 } |
(...skipping 11 matching lines...) Expand all Loading... |
2814 '/second.dart', | 2672 '/second.dart', |
2815 ''' | 2673 ''' |
2816 import 'first.dart'; | 2674 import 'first.dart'; |
2817 | 2675 |
2818 const b = a; | 2676 const b = a; |
2819 class M { | 2677 class M { |
2820 String c = a; | 2678 String c = a; |
2821 } | 2679 } |
2822 '''); | 2680 '''); |
2823 computeResult( | 2681 computeResult( |
2824 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT11, | 2682 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT10, |
2825 matcher: isInferInstanceMembersInUnitTask); | 2683 matcher: isInferInstanceMembersInUnitTask); |
2826 CompilationUnit firstUnit = outputs[RESOLVED_UNIT11]; | 2684 CompilationUnit firstUnit = outputs[RESOLVED_UNIT10]; |
2827 computeResult( | 2685 computeResult( |
2828 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT11); | 2686 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT10); |
2829 CompilationUnit secondUnit = outputs[RESOLVED_UNIT11]; | 2687 CompilationUnit secondUnit = outputs[RESOLVED_UNIT10]; |
2830 | 2688 |
2831 VariableDeclaration variableA = | 2689 VariableDeclaration variableA = |
2832 AstFinder.getTopLevelVariable(firstUnit, 'a'); | 2690 AstFinder.getTopLevelVariable(firstUnit, 'a'); |
2833 VariableDeclaration variableB = | 2691 VariableDeclaration variableB = |
2834 AstFinder.getTopLevelVariable(secondUnit, 'b'); | 2692 AstFinder.getTopLevelVariable(secondUnit, 'b'); |
2835 VariableDeclaration variableC = | 2693 VariableDeclaration variableC = |
2836 AstFinder.getFieldInClass(secondUnit, 'M', 'c'); | 2694 AstFinder.getFieldInClass(secondUnit, 'M', 'c'); |
2837 InterfaceType stringType = context.typeProvider.stringType; | 2695 InterfaceType stringType = context.typeProvider.stringType; |
2838 | 2696 |
2839 expect(variableA.element.type, stringType); | 2697 expect(variableA.element.type, stringType); |
2840 expect(variableB.element.type, stringType); | 2698 expect(variableB.element.type, stringType); |
2841 expect(variableB.initializer.staticType, stringType); | 2699 expect(variableB.initializer.staticType, stringType); |
2842 expect(variableC.element.type, stringType); | 2700 expect(variableC.element.type, stringType); |
2843 expect(variableC.initializer.staticType, stringType); | 2701 expect(variableC.initializer.staticType, stringType); |
2844 } | 2702 } |
2845 | 2703 |
2846 void test_perform_reresolution() { | 2704 void test_perform_reresolution() { |
2847 enableStrongMode(); | 2705 enableStrongMode(); |
2848 AnalysisTarget source = newSource( | 2706 AnalysisTarget source = newSource( |
2849 '/test.dart', | 2707 '/test.dart', |
2850 ''' | 2708 ''' |
2851 const topLevel = ''; | 2709 const topLevel = ''; |
2852 class C { | 2710 class C { |
2853 String field = topLevel; | 2711 String field = topLevel; |
2854 } | 2712 } |
2855 '''); | 2713 '''); |
2856 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); | 2714 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10); |
2857 CompilationUnit unit = outputs[RESOLVED_UNIT11]; | 2715 CompilationUnit unit = outputs[RESOLVED_UNIT10]; |
2858 VariableDeclaration topLevelDecl = | 2716 VariableDeclaration topLevelDecl = |
2859 AstFinder.getTopLevelVariable(unit, 'topLevel'); | 2717 AstFinder.getTopLevelVariable(unit, 'topLevel'); |
2860 VariableDeclaration fieldDecl = | 2718 VariableDeclaration fieldDecl = |
2861 AstFinder.getFieldInClass(unit, 'C', 'field'); | 2719 AstFinder.getFieldInClass(unit, 'C', 'field'); |
2862 VariableElement topLevel = topLevelDecl.name.staticElement; | 2720 VariableElement topLevel = topLevelDecl.name.staticElement; |
2863 VariableElement field = fieldDecl.name.staticElement; | 2721 VariableElement field = fieldDecl.name.staticElement; |
2864 | 2722 |
2865 InterfaceType stringType = context.typeProvider.stringType; | 2723 InterfaceType stringType = context.typeProvider.stringType; |
2866 expect(topLevel.type, stringType); | 2724 expect(topLevel.type, stringType); |
2867 expect(field.type, stringType); | 2725 expect(field.type, stringType); |
(...skipping 10 matching lines...) Expand all Loading... |
2878 } | 2736 } |
2879 | 2737 |
2880 test_created_resolved_unit() { | 2738 test_created_resolved_unit() { |
2881 Source source = newSource( | 2739 Source source = newSource( |
2882 '/test.dart', | 2740 '/test.dart', |
2883 r''' | 2741 r''' |
2884 library lib; | 2742 library lib; |
2885 class A {} | 2743 class A {} |
2886 '''); | 2744 '''); |
2887 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2745 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2888 computeResult(target, RESOLVED_UNIT9); | 2746 computeResult(target, RESOLVED_UNIT8); |
2889 expect(outputs[RESOLVED_UNIT9], isNotNull); | 2747 expect(outputs[RESOLVED_UNIT8], isNotNull); |
2890 expect(outputs[CREATED_RESOLVED_UNIT9], isTrue); | 2748 expect(outputs[CREATED_RESOLVED_UNIT8], isTrue); |
2891 } | 2749 } |
2892 | 2750 |
2893 void test_perform_const_field() { | 2751 void test_perform_const_field() { |
2894 enableStrongMode(); | 2752 enableStrongMode(); |
2895 AnalysisTarget source = newSource( | 2753 AnalysisTarget source = newSource( |
2896 '/test.dart', | 2754 '/test.dart', |
2897 ''' | 2755 ''' |
2898 class M { | 2756 class M { |
2899 static const X = ""; | 2757 static const X = ""; |
2900 } | 2758 } |
2901 '''); | 2759 '''); |
2902 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9, | 2760 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8, |
2903 matcher: isInferStaticVariableTypesInUnitTask); | 2761 matcher: isInferStaticVariableTypesInUnitTask); |
2904 CompilationUnit unit = outputs[RESOLVED_UNIT9]; | 2762 CompilationUnit unit = outputs[RESOLVED_UNIT8]; |
2905 VariableDeclaration declaration = AstFinder.getFieldInClass(unit, 'M', 'X'); | 2763 VariableDeclaration declaration = AstFinder.getFieldInClass(unit, 'M', 'X'); |
2906 InterfaceType stringType = context.typeProvider.stringType; | 2764 InterfaceType stringType = context.typeProvider.stringType; |
2907 expect(declaration.element.type, stringType); | 2765 expect(declaration.element.type, stringType); |
2908 } | 2766 } |
2909 | 2767 |
2910 test_perform_hasParseError() { | 2768 test_perform_hasParseError() { |
2911 Source source = newSource( | 2769 Source source = newSource( |
2912 '/test.dart', | 2770 '/test.dart', |
2913 r''' | 2771 r''' |
2914 @(i $= | 2772 @(i $= |
2915 '''); | 2773 '''); |
2916 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2774 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2917 computeResult(target, RESOLVED_UNIT9); | 2775 computeResult(target, RESOLVED_UNIT8); |
2918 expect(outputs[RESOLVED_UNIT9], isNotNull); | 2776 expect(outputs[RESOLVED_UNIT8], isNotNull); |
2919 expect(outputs[CREATED_RESOLVED_UNIT9], isTrue); | 2777 expect(outputs[CREATED_RESOLVED_UNIT8], isTrue); |
2920 } | 2778 } |
2921 | 2779 |
2922 void test_perform_nestedDeclarations() { | 2780 void test_perform_nestedDeclarations() { |
2923 enableStrongMode(); | 2781 enableStrongMode(); |
2924 AnalysisTarget source = newSource( | 2782 AnalysisTarget source = newSource( |
2925 '/test.dart', | 2783 '/test.dart', |
2926 ''' | 2784 ''' |
2927 var f = (int x) { | 2785 var f = (int x) { |
2928 int squared(int value) => value * value; | 2786 int squared(int value) => value * value; |
2929 var xSquared = squared(x); | 2787 var xSquared = squared(x); |
2930 return xSquared; | 2788 return xSquared; |
2931 }; | 2789 }; |
2932 '''); | 2790 '''); |
2933 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9, | 2791 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8, |
2934 matcher: isInferStaticVariableTypesInUnitTask); | 2792 matcher: isInferStaticVariableTypesInUnitTask); |
2935 } | 2793 } |
2936 | 2794 |
2937 void test_perform_recursive() { | 2795 void test_perform_recursive() { |
2938 enableStrongMode(); | 2796 enableStrongMode(); |
2939 AnalysisTarget firstSource = newSource( | 2797 AnalysisTarget firstSource = newSource( |
2940 '/first.dart', | 2798 '/first.dart', |
2941 ''' | 2799 ''' |
2942 import 'second.dart'; | 2800 import 'second.dart'; |
2943 | 2801 |
2944 var a = new M(); | 2802 var a = new M(); |
2945 var c = b; | 2803 var c = b; |
2946 '''); | 2804 '''); |
2947 AnalysisTarget secondSource = newSource( | 2805 AnalysisTarget secondSource = newSource( |
2948 '/second.dart', | 2806 '/second.dart', |
2949 ''' | 2807 ''' |
2950 import 'first.dart'; | 2808 import 'first.dart'; |
2951 | 2809 |
2952 var b = a; | 2810 var b = a; |
2953 class M {} | 2811 class M {} |
2954 '''); | 2812 '''); |
2955 computeResult( | 2813 computeResult( |
2956 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT9, | 2814 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT8, |
2957 matcher: isInferStaticVariableTypesInUnitTask); | 2815 matcher: isInferStaticVariableTypesInUnitTask); |
2958 CompilationUnit firstUnit = outputs[RESOLVED_UNIT9]; | 2816 CompilationUnit firstUnit = outputs[RESOLVED_UNIT8]; |
2959 computeResult( | 2817 computeResult( |
2960 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT9); | 2818 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT8); |
2961 CompilationUnit secondUnit = outputs[RESOLVED_UNIT9]; | 2819 CompilationUnit secondUnit = outputs[RESOLVED_UNIT8]; |
2962 | 2820 |
2963 VariableDeclaration variableA = | 2821 VariableDeclaration variableA = |
2964 AstFinder.getTopLevelVariable(firstUnit, 'a'); | 2822 AstFinder.getTopLevelVariable(firstUnit, 'a'); |
2965 VariableDeclaration variableB = | 2823 VariableDeclaration variableB = |
2966 AstFinder.getTopLevelVariable(secondUnit, 'b'); | 2824 AstFinder.getTopLevelVariable(secondUnit, 'b'); |
2967 VariableDeclaration variableC = | 2825 VariableDeclaration variableC = |
2968 AstFinder.getTopLevelVariable(firstUnit, 'c'); | 2826 AstFinder.getTopLevelVariable(firstUnit, 'c'); |
2969 ClassDeclaration classM = AstFinder.getClass(secondUnit, 'M'); | 2827 ClassDeclaration classM = AstFinder.getClass(secondUnit, 'M'); |
2970 DartType typeM = classM.element.type; | 2828 DartType typeM = classM.element.type; |
2971 | 2829 |
2972 expect(variableA.element.type, typeM); | 2830 expect(variableA.element.type, typeM); |
2973 expect(variableB.element.type, typeM); | 2831 expect(variableB.element.type, typeM); |
2974 expect(variableB.initializer.staticType, typeM); | 2832 expect(variableB.initializer.staticType, typeM); |
2975 expect(variableC.element.type, typeM); | 2833 expect(variableC.element.type, typeM); |
2976 expect(variableC.initializer.staticType, typeM); | 2834 expect(variableC.initializer.staticType, typeM); |
2977 } | 2835 } |
2978 | 2836 |
2979 void test_perform_simple() { | 2837 void test_perform_simple() { |
2980 enableStrongMode(); | 2838 enableStrongMode(); |
2981 AnalysisTarget source = newSource( | 2839 AnalysisTarget source = newSource( |
2982 '/test.dart', | 2840 '/test.dart', |
2983 ''' | 2841 ''' |
2984 var X = 1; | 2842 var X = 1; |
2985 | 2843 |
2986 var Y = () { | 2844 var Y = () { |
2987 return 1 + X; | 2845 return 1 + X; |
2988 }; | 2846 }; |
2989 '''); | 2847 '''); |
2990 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9, | 2848 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8, |
2991 matcher: isInferStaticVariableTypesInUnitTask); | 2849 matcher: isInferStaticVariableTypesInUnitTask); |
2992 CompilationUnit unit = outputs[RESOLVED_UNIT9]; | 2850 CompilationUnit unit = outputs[RESOLVED_UNIT8]; |
2993 TopLevelVariableDeclaration declaration = unit.declarations[1]; | 2851 TopLevelVariableDeclaration declaration = unit.declarations[1]; |
2994 FunctionExpression function = | 2852 FunctionExpression function = |
2995 declaration.variables.variables[0].initializer; | 2853 declaration.variables.variables[0].initializer; |
2996 BlockFunctionBody body = function.body; | 2854 BlockFunctionBody body = function.body; |
2997 ReturnStatement statement = body.block.statements[0]; | 2855 ReturnStatement statement = body.block.statements[0]; |
2998 Expression expression = statement.expression; | 2856 Expression expression = statement.expression; |
2999 InterfaceType intType = context.typeProvider.intType; | 2857 InterfaceType intType = context.typeProvider.intType; |
3000 expect(expression.staticType, intType); | 2858 expect(expression.staticType, intType); |
3001 } | 2859 } |
3002 | 2860 |
3003 test_staticModeHints_forStaticVariableInference() { | 2861 test_staticModeHints_forStaticVariableInference() { |
3004 context.analysisOptions = | 2862 context.analysisOptions = |
3005 new AnalysisOptionsImpl.from(context.analysisOptions) | 2863 new AnalysisOptionsImpl.from(context.analysisOptions) |
3006 ..strongModeHints = true; | 2864 ..strongModeHints = true; |
3007 Source source = newSource( | 2865 Source source = newSource( |
3008 '/test.dart', | 2866 '/test.dart', |
3009 r''' | 2867 r''' |
3010 var V = [42]; | 2868 var V = [42]; |
3011 '''); | 2869 '''); |
3012 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2870 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
3013 computeResult(target, RESOLVED_UNIT9); | 2871 computeResult(target, RESOLVED_UNIT8); |
3014 expect(outputs[RESOLVED_UNIT9], isNotNull); | 2872 expect(outputs[RESOLVED_UNIT8], isNotNull); |
3015 expect(outputs[CREATED_RESOLVED_UNIT9], isTrue); | 2873 expect(outputs[CREATED_RESOLVED_UNIT8], isTrue); |
3016 // An INFERRED_TYPE_LITERAL error should be generated. | 2874 // An INFERRED_TYPE_LITERAL error should be generated. |
3017 List<AnalysisError> errors = outputs[ | 2875 List<AnalysisError> errors = outputs[ |
3018 STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT] as List<AnalysisError>; | 2876 STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT] as List<AnalysisError>; |
3019 expect(errors, hasLength(1)); | 2877 expect(errors, hasLength(1)); |
3020 expect(errors[0].errorCode, StrongModeCode.INFERRED_TYPE_LITERAL); | 2878 expect(errors[0].errorCode, StrongModeCode.INFERRED_TYPE_LITERAL); |
3021 } | 2879 } |
3022 } | 2880 } |
3023 | 2881 |
3024 @reflectiveTest | 2882 @reflectiveTest |
3025 class InferStaticVariableTypeTaskTest extends _AbstractDartTaskTest { | 2883 class InferStaticVariableTypeTaskTest extends _AbstractDartTaskTest { |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 List<Source> sources = sourceList as List<Source>; | 3276 List<Source> sources = sourceList as List<Source>; |
3419 expect(sources, hasLength(lenght)); | 3277 expect(sources, hasLength(lenght)); |
3420 expect(sources, contains(predicate((Source s) { | 3278 expect(sources, contains(predicate((Source s) { |
3421 return s.fullName.endsWith('core.dart'); | 3279 return s.fullName.endsWith('core.dart'); |
3422 }))); | 3280 }))); |
3423 } | 3281 } |
3424 } | 3282 } |
3425 | 3283 |
3426 @reflectiveTest | 3284 @reflectiveTest |
3427 class PartiallyResolveUnitReferencesTaskTest extends _AbstractDartTaskTest { | 3285 class PartiallyResolveUnitReferencesTaskTest extends _AbstractDartTaskTest { |
3428 test_perform_propagable() { | |
3429 enableStrongMode(); | |
3430 Source source = newSource( | |
3431 '/test.dart', | |
3432 ''' | |
3433 const t1 = 1; | |
3434 final t2 = 2; | |
3435 var t3 = 3; | |
3436 final t4; | |
3437 class C { | |
3438 static const fs1 = 1; | |
3439 static final fs2 = 2; | |
3440 static var fs3 = 3; | |
3441 static final fs4; | |
3442 const fi1 = 1; | |
3443 final fi2 = 2; | |
3444 var fi3 = 3; | |
3445 final fi4; | |
3446 } | |
3447 '''); | |
3448 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
3449 computeResult(target, PROPAGABLE_VARIABLES_IN_UNIT, | |
3450 matcher: isPartiallyResolveUnitReferencesTask); | |
3451 // PROPAGABLE_VARIABLES_IN_UNIT | |
3452 List<VariableElement> variables = | |
3453 outputs[PROPAGABLE_VARIABLES_IN_UNIT] as List<VariableElement>; | |
3454 expect(variables.map((v) => v.displayName), | |
3455 unorderedEquals(['t1', 't2', 'fs1', 'fs2', 'fi1', 'fi2'])); | |
3456 } | |
3457 | |
3458 test_perform_strong_importExport() { | 3286 test_perform_strong_importExport() { |
3459 newSource( | 3287 newSource( |
3460 '/a.dart', | 3288 '/a.dart', |
3461 ''' | 3289 ''' |
3462 library a; | 3290 library a; |
3463 class A<T> { | 3291 class A<T> { |
3464 T m() {} | 3292 T m() {} |
3465 } | 3293 } |
3466 '''); | 3294 '''); |
3467 newSource( | 3295 newSource( |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3590 | 3418 |
3591 ConstructorDeclaration constructor = members[0]; | 3419 ConstructorDeclaration constructor = members[0]; |
3592 expectReference(constructor.body, false); | 3420 expectReference(constructor.body, false); |
3593 | 3421 |
3594 MethodDeclaration method = members[1]; | 3422 MethodDeclaration method = members[1]; |
3595 expectReference(method.body, false); | 3423 expectReference(method.body, false); |
3596 } | 3424 } |
3597 } | 3425 } |
3598 | 3426 |
3599 @reflectiveTest | 3427 @reflectiveTest |
3600 class PropagateVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { | |
3601 test_created_resolved_unit() { | |
3602 Source source = newSource( | |
3603 '/test.dart', | |
3604 r''' | |
3605 library lib; | |
3606 class A {} | |
3607 '''); | |
3608 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
3609 computeResult(target, RESOLVED_UNIT8); | |
3610 expect(outputs[RESOLVED_UNIT8], isNotNull); | |
3611 expect(outputs[CREATED_RESOLVED_UNIT8], isTrue); | |
3612 } | |
3613 | |
3614 void test_perform_cycle() { | |
3615 AnalysisTarget source = newSource( | |
3616 '/test.dart', | |
3617 ''' | |
3618 final piFirst = true; | |
3619 final pi = piFirst ? 3.14 : tau / 2; | |
3620 final tau = piFirst ? pi * 2 : 6.28; | |
3621 '''); | |
3622 // compute | |
3623 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8, | |
3624 matcher: isPropagateVariableTypesInUnitTask); | |
3625 CompilationUnit unit = outputs[RESOLVED_UNIT8]; | |
3626 // verify | |
3627 TopLevelVariableElement piFirst = | |
3628 AstFinder.getTopLevelVariableElement(unit, 'piFirst'); | |
3629 TopLevelVariableElement pi = | |
3630 AstFinder.getTopLevelVariableElement(unit, 'pi'); | |
3631 TopLevelVariableElement tau = | |
3632 AstFinder.getTopLevelVariableElement(unit, 'tau'); | |
3633 expect(piFirst.propagatedType, context.typeProvider.boolType); | |
3634 expect(pi.propagatedType, isNull); | |
3635 expect(tau.propagatedType, isNull); | |
3636 } | |
3637 | |
3638 void test_perform_topLevel() { | |
3639 AnalysisTarget source = newSource( | |
3640 '/test.dart', | |
3641 ''' | |
3642 //final a = b + c.length; | |
3643 final a = b; | |
3644 final b = 1; | |
3645 final c = '2'; | |
3646 '''); | |
3647 // compute | |
3648 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8, | |
3649 matcher: isPropagateVariableTypesInUnitTask); | |
3650 CompilationUnit unit = outputs[RESOLVED_UNIT8]; | |
3651 // verify | |
3652 InterfaceType intType = context.typeProvider.intType; | |
3653 InterfaceType stringType = context.typeProvider.stringType; | |
3654 expect(AstFinder.getTopLevelVariableElement(unit, 'a').propagatedType, | |
3655 intType); | |
3656 expect(AstFinder.getTopLevelVariableElement(unit, 'b').propagatedType, | |
3657 intType); | |
3658 expect(AstFinder.getTopLevelVariableElement(unit, 'c').propagatedType, | |
3659 stringType); | |
3660 } | |
3661 } | |
3662 | |
3663 @reflectiveTest | |
3664 class PropagateVariableTypeTaskTest extends _AbstractDartTaskTest { | |
3665 void test_perform_cycle() { | |
3666 AnalysisTarget source = newSource( | |
3667 '/test.dart', | |
3668 ''' | |
3669 final piFirst = true; | |
3670 final pi = piFirst ? 3.14 : tau / 2; | |
3671 final tau = piFirst ? pi * 2 : 6.28; | |
3672 '''); | |
3673 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7); | |
3674 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
3675 TopLevelVariableElement piFirst = | |
3676 AstFinder.getTopLevelVariableElement(unit, 'piFirst'); | |
3677 TopLevelVariableElement pi = | |
3678 AstFinder.getTopLevelVariableElement(unit, 'pi'); | |
3679 TopLevelVariableElement tau = | |
3680 AstFinder.getTopLevelVariableElement(unit, 'tau'); | |
3681 // compute | |
3682 computeResult(piFirst, PROPAGATED_VARIABLE, | |
3683 matcher: isPropagateVariableTypeTask); | |
3684 expect(piFirst.propagatedType, context.typeProvider.boolType); | |
3685 expect(pi.propagatedType, isNull); | |
3686 expect(tau.propagatedType, isNull); | |
3687 } | |
3688 | |
3689 void test_perform_null() { | |
3690 enableStrongMode(); | |
3691 AnalysisTarget source = newSource( | |
3692 '/test.dart', | |
3693 ''' | |
3694 var a = null; | |
3695 '''); | |
3696 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7); | |
3697 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
3698 TopLevelVariableElement a = AstFinder.getTopLevelVariableElement(unit, 'a'); | |
3699 // compute | |
3700 computeResult(a, PROPAGATED_VARIABLE, matcher: isPropagateVariableTypeTask); | |
3701 expect(a.propagatedType, isNull); | |
3702 } | |
3703 | |
3704 void test_perform_topLevel() { | |
3705 AnalysisTarget source = newSource( | |
3706 '/test.dart', | |
3707 ''' | |
3708 final a = b + c.length; | |
3709 final b = 1; | |
3710 final c = '2'; | |
3711 '''); | |
3712 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7); | |
3713 CompilationUnit unit = outputs[RESOLVED_UNIT7]; | |
3714 TopLevelVariableElement elementA = | |
3715 AstFinder.getTopLevelVariableElement(unit, 'a'); | |
3716 TopLevelVariableElement elementB = | |
3717 AstFinder.getTopLevelVariableElement(unit, 'b'); | |
3718 TopLevelVariableElement elementC = | |
3719 AstFinder.getTopLevelVariableElement(unit, 'c'); | |
3720 // compute | |
3721 computeResult(elementA, PROPAGATED_VARIABLE, | |
3722 matcher: isPropagateVariableTypeTask); | |
3723 InterfaceType intType = context.typeProvider.intType; | |
3724 InterfaceType stringType = context.typeProvider.stringType; | |
3725 expect(elementA.propagatedType, intType); | |
3726 expect(elementB.propagatedType, intType); | |
3727 expect(elementC.propagatedType, stringType); | |
3728 } | |
3729 } | |
3730 | |
3731 @reflectiveTest | |
3732 class ReferencedNamesBuilderTest extends _AbstractDartTaskTest { | 3428 class ReferencedNamesBuilderTest extends _AbstractDartTaskTest { |
3733 void setUp() { | 3429 void setUp() { |
3734 super.setUp(); | 3430 super.setUp(); |
3735 context.analysisOptions = new AnalysisOptionsImpl() | 3431 context.analysisOptions = new AnalysisOptionsImpl() |
3736 ..enableGenericMethods = true | 3432 ..enableGenericMethods = true |
3737 ..strongMode = true; | 3433 ..strongMode = true; |
3738 } | 3434 } |
3739 | 3435 |
3740 test_class_constructor() { | 3436 test_class_constructor() { |
3741 ReferencedNames info = _computeReferencedNames(''' | 3437 ReferencedNames info = _computeReferencedNames(''' |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4250 } | 3946 } |
4251 | 3947 |
4252 test_created_resolved_unit() { | 3948 test_created_resolved_unit() { |
4253 Source source = newSource( | 3949 Source source = newSource( |
4254 '/test.dart', | 3950 '/test.dart', |
4255 r''' | 3951 r''' |
4256 library lib; | 3952 library lib; |
4257 class A {} | 3953 class A {} |
4258 '''); | 3954 '''); |
4259 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 3955 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
4260 computeResult(target, RESOLVED_UNIT10); | 3956 computeResult(target, RESOLVED_UNIT9); |
4261 expect(outputs[RESOLVED_UNIT10], isNotNull); | 3957 expect(outputs[RESOLVED_UNIT9], isNotNull); |
4262 expect(outputs[CREATED_RESOLVED_UNIT10], isTrue); | 3958 expect(outputs[CREATED_RESOLVED_UNIT9], isTrue); |
4263 } | 3959 } |
4264 | 3960 |
4265 // Test inference of instance fields across units | 3961 // Test inference of instance fields across units |
4266 void test_perform_inference_cross_unit_instance() { | 3962 void test_perform_inference_cross_unit_instance() { |
4267 List<Source> sources = newSources({ | 3963 List<Source> sources = newSources({ |
4268 '/a.dart': ''' | 3964 '/a.dart': ''' |
4269 import 'b.dart'; | 3965 import 'b.dart'; |
4270 class A { | 3966 class A { |
4271 final a2 = new B().b2; | 3967 final a2 = new B().b2; |
4272 } | 3968 } |
4273 ''', | 3969 ''', |
4274 '/b.dart': ''' | 3970 '/b.dart': ''' |
4275 class B { | 3971 class B { |
4276 final b2 = 1; | 3972 final b2 = 1; |
4277 } | 3973 } |
4278 ''', | 3974 ''', |
4279 '/main.dart': ''' | 3975 '/main.dart': ''' |
4280 import "a.dart"; | 3976 import "a.dart"; |
4281 | 3977 |
4282 test1() { | 3978 test1() { |
4283 int x = 0; | 3979 int x = 0; |
4284 x = new A().a2; | 3980 x = new A().a2; |
4285 } | 3981 } |
4286 ''' | 3982 ''' |
4287 }); | 3983 }); |
4288 InterfaceType intType = context.typeProvider.intType; | 3984 InterfaceType intType = context.typeProvider.intType; |
4289 DartType dynamicType = context.typeProvider.dynamicType; | 3985 DartType dynamicType = context.typeProvider.dynamicType; |
4290 | 3986 |
4291 computeResult( | 3987 computeResult( |
4292 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT10); | 3988 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT9); |
4293 CompilationUnit unit1 = outputs[RESOLVED_UNIT10]; | 3989 CompilationUnit unit1 = outputs[RESOLVED_UNIT9]; |
4294 | 3990 |
4295 // B.b2 shoud be resolved on the rhs, but not yet inferred. | 3991 // B.b2 shoud be resolved on the rhs, but not yet inferred. |
4296 assertVariableDeclarationTypes( | 3992 assertVariableDeclarationTypes( |
4297 AstFinder.getFieldInClass(unit1, "B", "b2"), dynamicType, intType); | 3993 AstFinder.getFieldInClass(unit1, "B", "b2"), dynamicType, intType); |
4298 | 3994 |
4299 computeResult( | 3995 computeResult( |
4300 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10); | 3996 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9); |
4301 CompilationUnit unit0 = outputs[RESOLVED_UNIT10]; | 3997 CompilationUnit unit0 = outputs[RESOLVED_UNIT9]; |
4302 | 3998 |
4303 // B.b2 should now be fully resolved and inferred. | 3999 // B.b2 should now be fully resolved and inferred. |
4304 assertVariableDeclarationTypes( | 4000 assertVariableDeclarationTypes( |
4305 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); | 4001 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); |
4306 | 4002 |
4307 // A.a2 should now be resolved on the rhs, but not yet inferred. | 4003 // A.a2 should now be resolved on the rhs, but not yet inferred. |
4308 assertVariableDeclarationTypes( | 4004 assertVariableDeclarationTypes( |
4309 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, intType); | 4005 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, intType); |
4310 | 4006 |
4311 computeResult( | 4007 computeResult( |
4312 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT10); | 4008 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT9); |
4313 | 4009 |
4314 // A.a2 should now be fully resolved and inferred. | 4010 // A.a2 should now be fully resolved and inferred. |
4315 assertVariableDeclarationTypes( | 4011 assertVariableDeclarationTypes( |
4316 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); | 4012 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); |
4317 | 4013 |
4318 assertVariableDeclarationTypes( | 4014 assertVariableDeclarationTypes( |
4319 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); | 4015 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); |
4320 } | 4016 } |
4321 | 4017 |
4322 // Test inference of instance fields across units | 4018 // Test inference of instance fields across units |
(...skipping 16 matching lines...) Expand all Loading... |
4339 | 4035 |
4340 test1() { | 4036 test1() { |
4341 int x = 0; | 4037 int x = 0; |
4342 x = new A().a2; | 4038 x = new A().a2; |
4343 } | 4039 } |
4344 ''' | 4040 ''' |
4345 }); | 4041 }); |
4346 DartType dynamicType = context.typeProvider.dynamicType; | 4042 DartType dynamicType = context.typeProvider.dynamicType; |
4347 | 4043 |
4348 computeResult( | 4044 computeResult( |
4349 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10); | 4045 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9); |
4350 CompilationUnit unit0 = outputs[RESOLVED_UNIT10]; | 4046 CompilationUnit unit0 = outputs[RESOLVED_UNIT9]; |
4351 | 4047 |
4352 // A.a2 should now be resolved on the rhs, but not yet inferred. | 4048 // A.a2 should now be resolved on the rhs, but not yet inferred. |
4353 assertVariableDeclarationTypes( | 4049 assertVariableDeclarationTypes( |
4354 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 4050 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
4355 | 4051 |
4356 computeResult( | 4052 computeResult( |
4357 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT10); | 4053 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT9); |
4358 | 4054 |
4359 // A.a2 should now be fully resolved and inferred (but not re-resolved). | 4055 // A.a2 should now be fully resolved and inferred (but not re-resolved). |
4360 assertVariableDeclarationTypes( | 4056 assertVariableDeclarationTypes( |
4361 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 4057 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
4362 } | 4058 } |
4363 | 4059 |
4364 // Test inference of instance fields across units with cycles | 4060 // Test inference of instance fields across units with cycles |
4365 void test_perform_inference_cross_unit_static_instance() { | 4061 void test_perform_inference_cross_unit_static_instance() { |
4366 List<Source> sources = newSources({ | 4062 List<Source> sources = newSources({ |
4367 '/a.dart': ''' | 4063 '/a.dart': ''' |
(...skipping 17 matching lines...) Expand all Loading... |
4385 // inference in A now works. | 4081 // inference in A now works. |
4386 x = A.a1; | 4082 x = A.a1; |
4387 x = new A().a2; | 4083 x = new A().a2; |
4388 } | 4084 } |
4389 ''' | 4085 ''' |
4390 }); | 4086 }); |
4391 InterfaceType intType = context.typeProvider.intType; | 4087 InterfaceType intType = context.typeProvider.intType; |
4392 DartType dynamicType = context.typeProvider.dynamicType; | 4088 DartType dynamicType = context.typeProvider.dynamicType; |
4393 | 4089 |
4394 computeResult( | 4090 computeResult( |
4395 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT10); | 4091 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT9); |
4396 CompilationUnit unit1 = outputs[RESOLVED_UNIT10]; | 4092 CompilationUnit unit1 = outputs[RESOLVED_UNIT9]; |
4397 | 4093 |
4398 assertVariableDeclarationTypes( | 4094 assertVariableDeclarationTypes( |
4399 AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType); | 4095 AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType); |
4400 assertVariableDeclarationTypes( | 4096 assertVariableDeclarationTypes( |
4401 AstFinder.getFieldInClass(unit1, "B", "b2"), dynamicType, intType); | 4097 AstFinder.getFieldInClass(unit1, "B", "b2"), dynamicType, intType); |
4402 | 4098 |
4403 computeResult( | 4099 computeResult( |
4404 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10); | 4100 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9); |
4405 CompilationUnit unit0 = outputs[RESOLVED_UNIT10]; | 4101 CompilationUnit unit0 = outputs[RESOLVED_UNIT9]; |
4406 | 4102 |
4407 assertVariableDeclarationTypes( | 4103 assertVariableDeclarationTypes( |
4408 AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType); | 4104 AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType); |
4409 assertVariableDeclarationTypes( | 4105 assertVariableDeclarationTypes( |
4410 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, intType); | 4106 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, intType); |
4411 | 4107 |
4412 assertVariableDeclarationTypes( | 4108 assertVariableDeclarationTypes( |
4413 AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType); | 4109 AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType); |
4414 assertVariableDeclarationTypes( | 4110 assertVariableDeclarationTypes( |
4415 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); | 4111 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); |
4416 | 4112 |
4417 computeResult( | 4113 computeResult( |
4418 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT10); | 4114 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT9); |
4419 | 4115 |
4420 assertVariableDeclarationTypes( | 4116 assertVariableDeclarationTypes( |
4421 AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType); | 4117 AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType); |
4422 assertVariableDeclarationTypes( | 4118 assertVariableDeclarationTypes( |
4423 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); | 4119 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); |
4424 | 4120 |
4425 assertVariableDeclarationTypes( | 4121 assertVariableDeclarationTypes( |
4426 AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType); | 4122 AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType); |
4427 assertVariableDeclarationTypes( | 4123 assertVariableDeclarationTypes( |
4428 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); | 4124 AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType); |
(...skipping 18 matching lines...) Expand all Loading... |
4447 test1() { | 4143 test1() { |
4448 int x = 0; | 4144 int x = 0; |
4449 x = new A().a2; | 4145 x = new A().a2; |
4450 } | 4146 } |
4451 ''' | 4147 ''' |
4452 }); | 4148 }); |
4453 InterfaceType intType = context.typeProvider.intType; | 4149 InterfaceType intType = context.typeProvider.intType; |
4454 DartType dynamicType = context.typeProvider.dynamicType; | 4150 DartType dynamicType = context.typeProvider.dynamicType; |
4455 | 4151 |
4456 computeResult( | 4152 computeResult( |
4457 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10); | 4153 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9); |
4458 CompilationUnit unit0 = outputs[RESOLVED_UNIT10]; | 4154 CompilationUnit unit0 = outputs[RESOLVED_UNIT9]; |
4459 | 4155 |
4460 // A.a2 should now be resolved on the rhs, but not yet inferred. | 4156 // A.a2 should now be resolved on the rhs, but not yet inferred. |
4461 assertVariableDeclarationTypes( | 4157 assertVariableDeclarationTypes( |
4462 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 4158 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
4463 | 4159 |
4464 // B.b2 shoud be resolved on the rhs, but not yet inferred. | 4160 // B.b2 shoud be resolved on the rhs, but not yet inferred. |
4465 assertVariableDeclarationTypes( | 4161 assertVariableDeclarationTypes( |
4466 AstFinder.getFieldInClass(unit0, "B", "b2"), dynamicType, intType); | 4162 AstFinder.getFieldInClass(unit0, "B", "b2"), dynamicType, intType); |
4467 | 4163 |
4468 computeResult( | 4164 computeResult( |
4469 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT10); | 4165 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT9); |
4470 | 4166 |
4471 // A.a2 should now be fully resolved and inferred (but not re-resolved). | 4167 // A.a2 should now be fully resolved and inferred (but not re-resolved). |
4472 assertVariableDeclarationTypes( | 4168 assertVariableDeclarationTypes( |
4473 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 4169 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
4474 | 4170 |
4475 // B.b2 should now be fully resolved and inferred. | 4171 // B.b2 should now be fully resolved and inferred. |
4476 assertVariableDeclarationTypes( | 4172 assertVariableDeclarationTypes( |
4477 AstFinder.getFieldInClass(unit0, "B", "b2"), intType, intType); | 4173 AstFinder.getFieldInClass(unit0, "B", "b2"), intType, intType); |
4478 } | 4174 } |
4479 } | 4175 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4696 @reflectiveTest | 4392 @reflectiveTest |
4697 class ResolveUnitTaskTest extends _AbstractDartTaskTest { | 4393 class ResolveUnitTaskTest extends _AbstractDartTaskTest { |
4698 test_created_resolved_unit() { | 4394 test_created_resolved_unit() { |
4699 Source source = newSource( | 4395 Source source = newSource( |
4700 '/test.dart', | 4396 '/test.dart', |
4701 r''' | 4397 r''' |
4702 library lib; | 4398 library lib; |
4703 class A {} | 4399 class A {} |
4704 '''); | 4400 '''); |
4705 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 4401 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
4706 computeResult(target, RESOLVED_UNIT12); | 4402 computeResult(target, RESOLVED_UNIT11); |
4707 expect(outputs[RESOLVED_UNIT12], isNotNull); | 4403 expect(outputs[RESOLVED_UNIT11], isNotNull); |
4708 expect(outputs[CREATED_RESOLVED_UNIT12], isTrue); | 4404 expect(outputs[CREATED_RESOLVED_UNIT11], isTrue); |
4709 } | 4405 } |
4710 | 4406 |
4711 void test_perform() { | 4407 void test_perform() { |
4712 AnalysisTarget source = newSource( | 4408 AnalysisTarget source = newSource( |
4713 '/test.dart', | 4409 '/test.dart', |
4714 ''' | 4410 ''' |
4715 void f() { | 4411 void f() { |
4716 var c = new C(); | 4412 var c = new C(); |
4717 c.m(); | 4413 c.m(); |
4718 } | 4414 } |
4719 class C { | 4415 class C { |
4720 void m() { | 4416 void m() { |
4721 f(); | 4417 f(); |
4722 } | 4418 } |
4723 } | 4419 } |
4724 '''); | 4420 '''); |
4725 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12, | 4421 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11, |
4726 matcher: isResolveUnitTask); | 4422 matcher: isResolveUnitTask); |
4727 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 4423 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
4728 | 4424 |
4729 FunctionDeclaration f = unit.declarations[0]; | 4425 FunctionDeclaration f = unit.declarations[0]; |
4730 _assertResolved(f.functionExpression.body); | 4426 _assertResolved(f.functionExpression.body); |
4731 | 4427 |
4732 MethodDeclaration m = (unit.declarations[1] as ClassDeclaration).members[0]; | 4428 MethodDeclaration m = (unit.declarations[1] as ClassDeclaration).members[0]; |
4733 _assertResolved(m.body); | 4429 _assertResolved(m.body); |
4734 | 4430 |
4735 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); | 4431 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); |
4736 } | 4432 } |
4737 | 4433 |
4738 void test_perform_ensurePropagatedVariableTypes() { | |
4739 newSource( | |
4740 '/lib.dart', | |
4741 ''' | |
4742 class A { | |
4743 final v = 1; | |
4744 } | |
4745 '''); | |
4746 AnalysisTarget source = newSource( | |
4747 '/test.dart', | |
4748 ''' | |
4749 import 'lib.dart'; | |
4750 main(A a) { | |
4751 a.v.isEven; | |
4752 } | |
4753 '''); | |
4754 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12, | |
4755 matcher: isResolveUnitTask); | |
4756 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); | |
4757 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | |
4758 FunctionDeclaration main = unit.declarations[0]; | |
4759 BlockFunctionBody body = main.functionExpression.body; | |
4760 ExpressionStatement statement = body.block.statements.single; | |
4761 Expression expression = statement.expression; | |
4762 expect(expression.bestType, context.typeProvider.boolType); | |
4763 } | |
4764 | |
4765 void _assertResolved(FunctionBody body) { | 4434 void _assertResolved(FunctionBody body) { |
4766 ResolutionVerifier verifier = new ResolutionVerifier(); | 4435 ResolutionVerifier verifier = new ResolutionVerifier(); |
4767 body.accept(verifier); | 4436 body.accept(verifier); |
4768 verifier.assertResolved(); | 4437 verifier.assertResolved(); |
4769 } | 4438 } |
4770 } | 4439 } |
4771 | 4440 |
4772 @reflectiveTest | 4441 @reflectiveTest |
4773 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { | 4442 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { |
4774 test_created_resolved_unit() { | 4443 test_created_resolved_unit() { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5049 // Check that even within a static variable cycle, inferred | 4718 // Check that even within a static variable cycle, inferred |
5050 // types get propagated to the members of the cycle. | 4719 // types get propagated to the members of the cycle. |
5051 void test_perform_cycle() { | 4720 void test_perform_cycle() { |
5052 AnalysisTarget source = newSource( | 4721 AnalysisTarget source = newSource( |
5053 '/test.dart', | 4722 '/test.dart', |
5054 ''' | 4723 ''' |
5055 var piFirst = true; | 4724 var piFirst = true; |
5056 var pi = piFirst ? 3.14 : tau / 2; | 4725 var pi = piFirst ? 3.14 : tau / 2; |
5057 var tau = piFirst ? pi * 2 : 6.28; | 4726 var tau = piFirst ? pi * 2 : 6.28; |
5058 '''); | 4727 '''); |
5059 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); | 4728 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); |
5060 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 4729 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
5061 VariableElement piFirst = | 4730 VariableElement piFirst = |
5062 AstFinder.getTopLevelVariable(unit, 'piFirst').name.staticElement; | 4731 AstFinder.getTopLevelVariable(unit, 'piFirst').name.staticElement; |
5063 VariableElement pi = | 4732 VariableElement pi = |
5064 AstFinder.getTopLevelVariable(unit, 'pi').name.staticElement; | 4733 AstFinder.getTopLevelVariable(unit, 'pi').name.staticElement; |
5065 VariableElement tau = | 4734 VariableElement tau = |
5066 AstFinder.getTopLevelVariable(unit, 'tau').name.staticElement; | 4735 AstFinder.getTopLevelVariable(unit, 'tau').name.staticElement; |
5067 Expression piFirstUse = (AstFinder | 4736 Expression piFirstUse = (AstFinder |
5068 .getTopLevelVariable(unit, 'tau') | 4737 .getTopLevelVariable(unit, 'tau') |
5069 .initializer as ConditionalExpression) | 4738 .initializer as ConditionalExpression) |
5070 .condition; | 4739 .condition; |
(...skipping 21 matching lines...) Expand all Loading... |
5092 | 4761 |
5093 test1() { | 4762 test1() { |
5094 int t = 3; | 4763 int t = 3; |
5095 t = x; | 4764 t = x; |
5096 t = y; | 4765 t = y; |
5097 t = A.x; | 4766 t = A.x; |
5098 t = B.y; | 4767 t = B.y; |
5099 } | 4768 } |
5100 '''); | 4769 '''); |
5101 computeResult( | 4770 computeResult( |
5102 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT12); | 4771 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT11); |
5103 CompilationUnit unit1 = outputs[RESOLVED_UNIT12]; | 4772 CompilationUnit unit1 = outputs[RESOLVED_UNIT11]; |
5104 computeResult( | 4773 computeResult( |
5105 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT12); | 4774 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT11); |
5106 CompilationUnit unit2 = outputs[RESOLVED_UNIT12]; | 4775 CompilationUnit unit2 = outputs[RESOLVED_UNIT11]; |
5107 | 4776 |
5108 InterfaceType intType = context.typeProvider.intType; | 4777 InterfaceType intType = context.typeProvider.intType; |
5109 | 4778 |
5110 assertVariableDeclarationTypes( | 4779 assertVariableDeclarationTypes( |
5111 AstFinder.getTopLevelVariable(unit1, "x"), intType, intType); | 4780 AstFinder.getTopLevelVariable(unit1, "x"), intType, intType); |
5112 assertVariableDeclarationTypes( | 4781 assertVariableDeclarationTypes( |
5113 AstFinder.getFieldInClass(unit1, "A", "x"), intType, intType); | 4782 AstFinder.getFieldInClass(unit1, "A", "x"), intType, intType); |
5114 | 4783 |
5115 assertVariableDeclarationTypes( | 4784 assertVariableDeclarationTypes( |
5116 AstFinder.getTopLevelVariable(unit2, "y"), intType, intType); | 4785 AstFinder.getTopLevelVariable(unit2, "y"), intType, intType); |
(...skipping 26 matching lines...) Expand all Loading... |
5143 '/main.dart': ''' | 4812 '/main.dart': ''' |
5144 import "a.dart"; | 4813 import "a.dart"; |
5145 | 4814 |
5146 test1() { | 4815 test1() { |
5147 int x = 0; | 4816 int x = 0; |
5148 x = new A().a2; | 4817 x = new A().a2; |
5149 } | 4818 } |
5150 ''' | 4819 ''' |
5151 }); | 4820 }); |
5152 List<dynamic> units = | 4821 List<dynamic> units = |
5153 computeLibraryResults(sources, RESOLVED_UNIT12).toList(); | 4822 computeLibraryResults(sources, RESOLVED_UNIT11).toList(); |
5154 CompilationUnit unit0 = units[0]; | 4823 CompilationUnit unit0 = units[0]; |
5155 CompilationUnit unit1 = units[1]; | 4824 CompilationUnit unit1 = units[1]; |
5156 CompilationUnit unit2 = units[2]; | 4825 CompilationUnit unit2 = units[2]; |
5157 | 4826 |
5158 InterfaceType intType = context.typeProvider.intType; | 4827 InterfaceType intType = context.typeProvider.intType; |
5159 | 4828 |
5160 assertVariableDeclarationTypes( | 4829 assertVariableDeclarationTypes( |
5161 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); | 4830 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); |
5162 | 4831 |
5163 assertVariableDeclarationTypes( | 4832 assertVariableDeclarationTypes( |
(...skipping 26 matching lines...) Expand all Loading... |
5190 ''', | 4859 ''', |
5191 '/c.dart': ''' | 4860 '/c.dart': ''' |
5192 import 'b.dart'; | 4861 import 'b.dart'; |
5193 var bar = new B(); | 4862 var bar = new B(); |
5194 void foo() { | 4863 void foo() { |
5195 String x = bar.f.z; | 4864 String x = bar.f.z; |
5196 } | 4865 } |
5197 ''' | 4866 ''' |
5198 }); | 4867 }); |
5199 List<dynamic> units = | 4868 List<dynamic> units = |
5200 computeLibraryResults(sources, RESOLVED_UNIT12).toList(); | 4869 computeLibraryResults(sources, RESOLVED_UNIT11).toList(); |
5201 CompilationUnit unit0 = units[0]; | 4870 CompilationUnit unit0 = units[0]; |
5202 CompilationUnit unit2 = units[2]; | 4871 CompilationUnit unit2 = units[2]; |
5203 | 4872 |
5204 InterfaceType intType = context.typeProvider.intType; | 4873 InterfaceType intType = context.typeProvider.intType; |
5205 InterfaceType stringType = context.typeProvider.stringType; | 4874 InterfaceType stringType = context.typeProvider.stringType; |
5206 | 4875 |
5207 assertVariableDeclarationStatementTypes( | 4876 assertVariableDeclarationStatementTypes( |
5208 AstFinder.getStatementsInTopLevelFunction(unit0, "foo")[0], | 4877 AstFinder.getStatementsInTopLevelFunction(unit0, "foo")[0], |
5209 stringType, | 4878 stringType, |
5210 intType); | 4879 intType); |
(...skipping 20 matching lines...) Expand all Loading... |
5231 class B { static var y = A.x; } | 4900 class B { static var y = A.x; } |
5232 | 4901 |
5233 test1() { | 4902 test1() { |
5234 x = /*severe:StaticTypeError*/"hi"; | 4903 x = /*severe:StaticTypeError*/"hi"; |
5235 y = /*severe:StaticTypeError*/"hi"; | 4904 y = /*severe:StaticTypeError*/"hi"; |
5236 A.x = /*severe:StaticTypeError*/"hi"; | 4905 A.x = /*severe:StaticTypeError*/"hi"; |
5237 B.y = /*severe:StaticTypeError*/"hi"; | 4906 B.y = /*severe:StaticTypeError*/"hi"; |
5238 } | 4907 } |
5239 '''); | 4908 '''); |
5240 computeResult( | 4909 computeResult( |
5241 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT12); | 4910 new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT11); |
5242 CompilationUnit unit1 = outputs[RESOLVED_UNIT12]; | 4911 CompilationUnit unit1 = outputs[RESOLVED_UNIT11]; |
5243 computeResult( | 4912 computeResult( |
5244 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT12); | 4913 new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT11); |
5245 CompilationUnit unit2 = outputs[RESOLVED_UNIT12]; | 4914 CompilationUnit unit2 = outputs[RESOLVED_UNIT11]; |
5246 | 4915 |
5247 InterfaceType intType = context.typeProvider.intType; | 4916 InterfaceType intType = context.typeProvider.intType; |
5248 InterfaceType stringType = context.typeProvider.stringType; | 4917 InterfaceType stringType = context.typeProvider.stringType; |
5249 | 4918 |
5250 assertVariableDeclarationTypes( | 4919 assertVariableDeclarationTypes( |
5251 AstFinder.getTopLevelVariable(unit1, "x"), intType, intType); | 4920 AstFinder.getTopLevelVariable(unit1, "x"), intType, intType); |
5252 assertVariableDeclarationTypes( | 4921 assertVariableDeclarationTypes( |
5253 AstFinder.getFieldInClass(unit1, "A", "x"), intType, intType); | 4922 AstFinder.getFieldInClass(unit1, "A", "x"), intType, intType); |
5254 | 4923 |
5255 assertVariableDeclarationTypes( | 4924 assertVariableDeclarationTypes( |
(...skipping 29 matching lines...) Expand all Loading... |
5285 | 4954 |
5286 test1() { | 4955 test1() { |
5287 int x = 0; | 4956 int x = 0; |
5288 // inference in A now works. | 4957 // inference in A now works. |
5289 x = A.a1; | 4958 x = A.a1; |
5290 x = new A().a2; | 4959 x = new A().a2; |
5291 } | 4960 } |
5292 ''' | 4961 ''' |
5293 }); | 4962 }); |
5294 List<dynamic> units = | 4963 List<dynamic> units = |
5295 computeLibraryResults(sources, RESOLVED_UNIT12).toList(); | 4964 computeLibraryResults(sources, RESOLVED_UNIT11).toList(); |
5296 CompilationUnit unit0 = units[0]; | 4965 CompilationUnit unit0 = units[0]; |
5297 CompilationUnit unit1 = units[1]; | 4966 CompilationUnit unit1 = units[1]; |
5298 CompilationUnit unit2 = units[2]; | 4967 CompilationUnit unit2 = units[2]; |
5299 | 4968 |
5300 InterfaceType intType = context.typeProvider.intType; | 4969 InterfaceType intType = context.typeProvider.intType; |
5301 | 4970 |
5302 assertVariableDeclarationTypes( | 4971 assertVariableDeclarationTypes( |
5303 AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType); | 4972 AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType); |
5304 assertVariableDeclarationTypes( | 4973 assertVariableDeclarationTypes( |
5305 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); | 4974 AstFinder.getFieldInClass(unit0, "A", "a2"), intType, intType); |
(...skipping 15 matching lines...) Expand all Loading... |
5321 AnalysisTarget source = newSource( | 4990 AnalysisTarget source = newSource( |
5322 '/test.dart', | 4991 '/test.dart', |
5323 ''' | 4992 ''' |
5324 test() { | 4993 test() { |
5325 int x = 3; | 4994 int x = 3; |
5326 x = "hi"; | 4995 x = "hi"; |
5327 var y = 3; | 4996 var y = 3; |
5328 y = "hi"; | 4997 y = "hi"; |
5329 } | 4998 } |
5330 '''); | 4999 '''); |
5331 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); | 5000 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); |
5332 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 5001 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
5333 | 5002 |
5334 InterfaceType intType = context.typeProvider.intType; | 5003 InterfaceType intType = context.typeProvider.intType; |
5335 InterfaceType stringType = context.typeProvider.stringType; | 5004 InterfaceType stringType = context.typeProvider.stringType; |
5336 | 5005 |
5337 List<Statement> statements = | 5006 List<Statement> statements = |
5338 AstFinder.getStatementsInTopLevelFunction(unit, "test"); | 5007 AstFinder.getStatementsInTopLevelFunction(unit, "test"); |
5339 | 5008 |
5340 assertVariableDeclarationStatementTypes(statements[0], intType, intType); | 5009 assertVariableDeclarationStatementTypes(statements[0], intType, intType); |
5341 assertAssignmentStatementTypes(statements[1], intType, stringType); | 5010 assertAssignmentStatementTypes(statements[1], intType, stringType); |
5342 assertVariableDeclarationStatementTypes(statements[2], intType, intType); | 5011 assertVariableDeclarationStatementTypes(statements[2], intType, intType); |
(...skipping 17 matching lines...) Expand all Loading... |
5360 b = 4; | 5029 b = 4; |
5361 var c = z; | 5030 var c = z; |
5362 c = "hi"; | 5031 c = "hi"; |
5363 c = 4; | 5032 c = 4; |
5364 } | 5033 } |
5365 | 5034 |
5366 int y; // field def after use | 5035 int y; // field def after use |
5367 final z = 42; // should infer `int` | 5036 final z = 42; // should infer `int` |
5368 } | 5037 } |
5369 '''); | 5038 '''); |
5370 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); | 5039 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); |
5371 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 5040 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
5372 | 5041 |
5373 InterfaceType intType = context.typeProvider.intType; | 5042 InterfaceType intType = context.typeProvider.intType; |
5374 InterfaceType stringType = context.typeProvider.stringType; | 5043 InterfaceType stringType = context.typeProvider.stringType; |
5375 | 5044 |
5376 List<Statement> statements = | 5045 List<Statement> statements = |
5377 AstFinder.getStatementsInMethod(unit, "A", "test1"); | 5046 AstFinder.getStatementsInMethod(unit, "A", "test1"); |
5378 | 5047 |
5379 assertVariableDeclarationStatementTypes(statements[0], intType, intType); | 5048 assertVariableDeclarationStatementTypes(statements[0], intType, intType); |
5380 assertAssignmentStatementTypes(statements[1], intType, stringType); | 5049 assertAssignmentStatementTypes(statements[1], intType, stringType); |
5381 assertAssignmentStatementTypes(statements[2], intType, intType); | 5050 assertAssignmentStatementTypes(statements[2], intType, intType); |
(...skipping 27 matching lines...) Expand all Loading... |
5409 b = /*severe:StaticTypeError*/"hi"; | 5078 b = /*severe:StaticTypeError*/"hi"; |
5410 b = 4; | 5079 b = 4; |
5411 var c = z; | 5080 var c = z; |
5412 c = /*severe:StaticTypeError*/"hi"; | 5081 c = /*severe:StaticTypeError*/"hi"; |
5413 c = 4; | 5082 c = 4; |
5414 } | 5083 } |
5415 | 5084 |
5416 int y = 0; // field def after use | 5085 int y = 0; // field def after use |
5417 final z = 42; // should infer `int` | 5086 final z = 42; // should infer `int` |
5418 '''); | 5087 '''); |
5419 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); | 5088 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); |
5420 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 5089 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
5421 | 5090 |
5422 InterfaceType intType = context.typeProvider.intType; | 5091 InterfaceType intType = context.typeProvider.intType; |
5423 InterfaceType stringType = context.typeProvider.stringType; | 5092 InterfaceType stringType = context.typeProvider.stringType; |
5424 | 5093 |
5425 List<Statement> statements = | 5094 List<Statement> statements = |
5426 AstFinder.getStatementsInTopLevelFunction(unit, "test1"); | 5095 AstFinder.getStatementsInTopLevelFunction(unit, "test1"); |
5427 | 5096 |
5428 assertVariableDeclarationStatementTypes(statements[0], intType, intType); | 5097 assertVariableDeclarationStatementTypes(statements[0], intType, intType); |
5429 assertAssignmentStatementTypes(statements[1], intType, stringType); | 5098 assertAssignmentStatementTypes(statements[1], intType, stringType); |
5430 assertAssignmentStatementTypes(statements[2], intType, intType); | 5099 assertAssignmentStatementTypes(statements[2], intType, intType); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5462 | 5131 |
5463 test() { | 5132 test() { |
5464 x = "hi"; | 5133 x = "hi"; |
5465 y = /*severe:StaticTypeError*/"hi"; | 5134 y = /*severe:StaticTypeError*/"hi"; |
5466 A.x = "hi"; | 5135 A.x = "hi"; |
5467 A.y = /*severe:StaticTypeError*/"hi"; | 5136 A.y = /*severe:StaticTypeError*/"hi"; |
5468 new A().x2 = "hi"; | 5137 new A().x2 = "hi"; |
5469 new A().y2 = /*severe:StaticTypeError*/"hi"; | 5138 new A().y2 = /*severe:StaticTypeError*/"hi"; |
5470 } | 5139 } |
5471 '''); | 5140 '''); |
5472 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); | 5141 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); |
5473 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 5142 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
5474 | 5143 |
5475 InterfaceType intType = context.typeProvider.intType; | 5144 InterfaceType intType = context.typeProvider.intType; |
5476 InterfaceType stringType = context.typeProvider.stringType; | 5145 InterfaceType stringType = context.typeProvider.stringType; |
5477 DartType bottomType = context.typeProvider.bottomType; | 5146 DartType bottomType = context.typeProvider.bottomType; |
5478 DartType dynamicType = context.typeProvider.dynamicType; | 5147 DartType dynamicType = context.typeProvider.dynamicType; |
5479 | 5148 |
5480 assertVariableDeclarationTypes( | 5149 assertVariableDeclarationTypes( |
5481 AstFinder.getTopLevelVariable(unit, "x"), dynamicType, bottomType); | 5150 AstFinder.getTopLevelVariable(unit, "x"), dynamicType, bottomType); |
5482 assertVariableDeclarationTypes( | 5151 assertVariableDeclarationTypes( |
5483 AstFinder.getTopLevelVariable(unit, "y"), intType, intType); | 5152 AstFinder.getTopLevelVariable(unit, "y"), intType, intType); |
(...skipping 20 matching lines...) Expand all Loading... |
5504 // Test inference between fields and method bodies | 5173 // Test inference between fields and method bodies |
5505 void test_perform_local_explicit_disabled() { | 5174 void test_perform_local_explicit_disabled() { |
5506 AnalysisTarget source = newSource( | 5175 AnalysisTarget source = newSource( |
5507 '/test.dart', | 5176 '/test.dart', |
5508 ''' | 5177 ''' |
5509 test() { | 5178 test() { |
5510 int x = 3; | 5179 int x = 3; |
5511 x = "hi"; | 5180 x = "hi"; |
5512 } | 5181 } |
5513 '''); | 5182 '''); |
5514 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); | 5183 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11); |
5515 CompilationUnit unit = outputs[RESOLVED_UNIT12]; | 5184 CompilationUnit unit = outputs[RESOLVED_UNIT11]; |
5516 | 5185 |
5517 InterfaceType intType = context.typeProvider.intType; | 5186 InterfaceType intType = context.typeProvider.intType; |
5518 InterfaceType stringType = context.typeProvider.stringType; | 5187 InterfaceType stringType = context.typeProvider.stringType; |
5519 | 5188 |
5520 List<Statement> statements = | 5189 List<Statement> statements = |
5521 AstFinder.getStatementsInTopLevelFunction(unit, "test"); | 5190 AstFinder.getStatementsInTopLevelFunction(unit, "test"); |
5522 VariableDeclaration decl = | 5191 VariableDeclaration decl = |
5523 (statements[0] as VariableDeclarationStatement).variables.variables[0]; | 5192 (statements[0] as VariableDeclarationStatement).variables.variables[0]; |
5524 expect(decl.element.type, intType); | 5193 expect(decl.element.type, intType); |
5525 expect(decl.initializer.staticType, intType); | 5194 expect(decl.initializer.staticType, intType); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5872 /** | 5541 /** |
5873 * Fill [errorListener] with [result] errors in the current [task]. | 5542 * Fill [errorListener] with [result] errors in the current [task]. |
5874 */ | 5543 */ |
5875 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 5544 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
5876 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; | 5545 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; |
5877 expect(errors, isNotNull, reason: result.name); | 5546 expect(errors, isNotNull, reason: result.name); |
5878 errorListener = new GatheringErrorListener(); | 5547 errorListener = new GatheringErrorListener(); |
5879 errorListener.addAll(errors); | 5548 errorListener.addAll(errors); |
5880 } | 5549 } |
5881 } | 5550 } |
OLD | NEW |