Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 2288223003: Don't perform final fields and top-level variables type propagation. (Closed)
Patch Set: Rewrite 'reuse' tests using 'inferredTypeSlot'. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/task/dart_test.dart
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index c01223cff632f6699c954acd8493150c1a931e62..06b94cd6699ca64c1648eb83b7eaa6f99c83ffc1 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -49,7 +49,6 @@ main() {
runReflectiveTests(ComputeConstantValueTaskTest);
runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest);
runReflectiveTests(ComputeLibraryCycleTaskTest);
- runReflectiveTests(ComputePropagableVariableDependenciesTaskTest);
runReflectiveTests(ContainingLibrariesTaskTest);
runReflectiveTests(DartErrorsTaskTest);
runReflectiveTests(EvaluateUnitConstantsTaskTest);
@@ -64,8 +63,6 @@ main() {
runReflectiveTests(LibraryUnitErrorsTaskTest);
runReflectiveTests(ParseDartTaskTest);
runReflectiveTests(PartiallyResolveUnitReferencesTaskTest);
- runReflectiveTests(PropagateVariableTypesInUnitTaskTest);
- runReflectiveTests(PropagateVariableTypeTaskTest);
runReflectiveTests(ReferencedNamesBuilderTest);
runReflectiveTests(ResolveDirectiveElementsTaskTest);
runReflectiveTests(ResolveInstanceFieldsInUnitTaskTest);
@@ -103,8 +100,6 @@ isInstanceOf isComputeConstantValueTask =
new isInstanceOf<ComputeConstantValueTask>();
isInstanceOf isComputeInferableStaticVariableDependenciesTask =
new isInstanceOf<ComputeInferableStaticVariableDependenciesTask>();
-isInstanceOf isComputePropagableVariableDependenciesTask =
- new isInstanceOf<ComputePropagableVariableDependenciesTask>();
isInstanceOf isContainingLibrariesTask =
new isInstanceOf<ContainingLibrariesTask>();
isInstanceOf isDartErrorsTask = new isInstanceOf<DartErrorsTask>();
@@ -129,10 +124,6 @@ isInstanceOf isLibraryUnitErrorsTask =
isInstanceOf isParseDartTask = new isInstanceOf<ParseDartTask>();
isInstanceOf isPartiallyResolveUnitReferencesTask =
new isInstanceOf<PartiallyResolveUnitReferencesTask>();
-isInstanceOf isPropagateVariableTypesInUnitTask =
- new isInstanceOf<PropagateVariableTypesInUnitTask>();
-isInstanceOf isPropagateVariableTypeTask =
- new isInstanceOf<PropagateVariableTypeTask>();
isInstanceOf isResolveDirectiveElementsTask =
new isInstanceOf<ResolveDirectiveElementsTask>();
isInstanceOf isResolveLibraryReferencesTask =
@@ -2017,139 +2008,6 @@ import 'dart:core';
}
@reflectiveTest
-class ComputePropagableVariableDependenciesTaskTest
- extends _AbstractDartTaskTest {
- List<VariableElement> getPropagableVariableDependencies(
- Map<ResultDescriptor, dynamic> outputs) {
- return outputs[PROPAGABLE_VARIABLE_DEPENDENCIES] as List<VariableElement>;
- }
-
- test_perform_instanceField() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-class A {
- final a = a1 + a2 + a3 + a4 + B.b1 + B.b2 + B.b3 + B.b4;
- static const a1 = 1;
- final a2 = 2;
- final a3;
- var a4 = 4;
-}
-class B {
- static const b1 = 1;
- static final b2 = 2;
- static final b3;
- static var b4 = 4;
-}
-''');
- LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- FieldElement elementA = AstFinder.getFieldInClassElement(unit, 'A', 'a');
- // compute
- computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES,
- matcher: isComputePropagableVariableDependenciesTask);
- // verify
- expect(outputs, hasLength(1));
- List<VariableElement> dependencies =
- getPropagableVariableDependencies(outputs);
- expect(
- dependencies,
- unorderedEquals([
- AstFinder.getFieldInClassElement(unit, 'A', 'a1'),
- AstFinder.getFieldInClassElement(unit, 'A', 'a2'),
- AstFinder.getFieldInClassElement(unit, 'B', 'b1'),
- AstFinder.getFieldInClassElement(unit, 'B', 'b2')
- ]));
- }
-
- test_perform_topLevel() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-const a = d1 + d2 + d3 + d4;
-const d1 = 1;
-final d2 = 2;
-final d3;
-var d4 = 4;
-''');
- LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- TopLevelVariableElement elementA =
- AstFinder.getTopLevelVariableElement(unit, 'a');
- // compute
- computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES,
- matcher: isComputePropagableVariableDependenciesTask);
- // verify
- expect(outputs, hasLength(1));
- List<VariableElement> dependencies =
- getPropagableVariableDependencies(outputs);
- expect(
- dependencies,
- unorderedEquals([
- AstFinder.getTopLevelVariableElement(unit, 'd1'),
- AstFinder.getTopLevelVariableElement(unit, 'd2')
- ]));
- }
-
- test_perform_topLevel_ignoreLocal() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-final a = () {
- const b = 2;
- const c = 3;
- return b + c;
-}() + d;
-final d = 4;
-''');
- LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- TopLevelVariableElement elementA =
- AstFinder.getTopLevelVariableElement(unit, 'a');
- // compute
- computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES,
- matcher: isComputePropagableVariableDependenciesTask);
- // verify
- expect(outputs, hasLength(1));
- List<VariableElement> dependencies =
- getPropagableVariableDependencies(outputs);
- expect(dependencies,
- unorderedEquals([AstFinder.getTopLevelVariableElement(unit, 'd')]));
- }
-
- test_perform_topLevel_withoutSpaceAfterType() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-const List<int>a=[b, c];
-const b = 1;
-const c = 2;
-''');
- LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- TopLevelVariableElement elementA =
- AstFinder.getTopLevelVariableElement(unit, 'a');
- // compute
- computeResult(elementA, PROPAGABLE_VARIABLE_DEPENDENCIES,
- matcher: isComputePropagableVariableDependenciesTask);
- // verify
- expect(outputs, hasLength(1));
- List<VariableElement> dependencies =
- getPropagableVariableDependencies(outputs);
- expect(
- dependencies,
- unorderedEquals([
- AstFinder.getTopLevelVariableElement(unit, 'b'),
- AstFinder.getTopLevelVariableElement(unit, 'c')
- ]));
- }
-}
-
-@reflectiveTest
class ContainingLibrariesTaskTest extends _AbstractDartTaskTest {
List<Source> getContainingLibraries(Map<ResultDescriptor, dynamic> outputs) {
return outputs[CONTAINING_LIBRARIES] as List<Source>;
@@ -2237,9 +2095,9 @@ library lib;
class A {}
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT13);
- expect(outputs[RESOLVED_UNIT13], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT13], isTrue);
+ computeResult(target, RESOLVED_UNIT12);
+ expect(outputs[RESOLVED_UNIT12], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT12], isTrue);
}
test_perform() {
@@ -2256,9 +2114,9 @@ f() {}
const x = const C();
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT13,
+ computeResult(target, RESOLVED_UNIT12,
matcher: isEvaluateUnitConstantsTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT13];
+ CompilationUnit unit = outputs[RESOLVED_UNIT12];
CompilationUnitElement unitElement = unit.element;
expect(
(unitElement.types[0].constructors[0] as ConstructorElementImpl)
@@ -2765,9 +2623,9 @@ library lib;
class A {}
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT11);
- expect(outputs[RESOLVED_UNIT11], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT11], isTrue);
+ computeResult(target, RESOLVED_UNIT10);
+ expect(outputs[RESOLVED_UNIT10], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT10], isTrue);
}
void test_perform() {
@@ -2787,9 +2645,9 @@ class X {}
class Y {}
class Z {}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11,
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10,
matcher: isInferInstanceMembersInUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT11];
+ CompilationUnit unit = outputs[RESOLVED_UNIT10];
VariableDeclaration field = AstFinder.getFieldInClass(unit, 'B', 'f');
MethodDeclaration method = AstFinder.getMethodInClass(unit, 'B', 'm');
DartType typeX = AstFinder.getClass(unit, 'X').element.type;
@@ -2821,12 +2679,12 @@ class M {
}
''');
computeResult(
- new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT11,
+ new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT10,
matcher: isInferInstanceMembersInUnitTask);
- CompilationUnit firstUnit = outputs[RESOLVED_UNIT11];
+ CompilationUnit firstUnit = outputs[RESOLVED_UNIT10];
computeResult(
- new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT11);
- CompilationUnit secondUnit = outputs[RESOLVED_UNIT11];
+ new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT10);
+ CompilationUnit secondUnit = outputs[RESOLVED_UNIT10];
VariableDeclaration variableA =
AstFinder.getTopLevelVariable(firstUnit, 'a');
@@ -2853,8 +2711,8 @@ class C {
String field = topLevel;
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
- CompilationUnit unit = outputs[RESOLVED_UNIT11];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10);
+ CompilationUnit unit = outputs[RESOLVED_UNIT10];
VariableDeclaration topLevelDecl =
AstFinder.getTopLevelVariable(unit, 'topLevel');
VariableDeclaration fieldDecl =
@@ -2885,9 +2743,9 @@ library lib;
class A {}
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT9);
- expect(outputs[RESOLVED_UNIT9], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT9], isTrue);
+ computeResult(target, RESOLVED_UNIT8);
+ expect(outputs[RESOLVED_UNIT8], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT8], isTrue);
}
void test_perform_const_field() {
@@ -2899,9 +2757,9 @@ class M {
static const X = "";
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9,
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8,
matcher: isInferStaticVariableTypesInUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT9];
+ CompilationUnit unit = outputs[RESOLVED_UNIT8];
VariableDeclaration declaration = AstFinder.getFieldInClass(unit, 'M', 'X');
InterfaceType stringType = context.typeProvider.stringType;
expect(declaration.element.type, stringType);
@@ -2914,9 +2772,9 @@ class M {
@(i $=
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT9);
- expect(outputs[RESOLVED_UNIT9], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT9], isTrue);
+ computeResult(target, RESOLVED_UNIT8);
+ expect(outputs[RESOLVED_UNIT8], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT8], isTrue);
}
void test_perform_nestedDeclarations() {
@@ -2930,7 +2788,7 @@ var f = (int x) {
return xSquared;
};
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9,
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8,
matcher: isInferStaticVariableTypesInUnitTask);
}
@@ -2953,12 +2811,12 @@ var b = a;
class M {}
''');
computeResult(
- new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT9,
+ new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT8,
matcher: isInferStaticVariableTypesInUnitTask);
- CompilationUnit firstUnit = outputs[RESOLVED_UNIT9];
+ CompilationUnit firstUnit = outputs[RESOLVED_UNIT8];
computeResult(
- new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT9);
- CompilationUnit secondUnit = outputs[RESOLVED_UNIT9];
+ new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT8);
+ CompilationUnit secondUnit = outputs[RESOLVED_UNIT8];
VariableDeclaration variableA =
AstFinder.getTopLevelVariable(firstUnit, 'a');
@@ -2987,9 +2845,9 @@ var Y = () {
return 1 + X;
};
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT9,
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8,
matcher: isInferStaticVariableTypesInUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT9];
+ CompilationUnit unit = outputs[RESOLVED_UNIT8];
TopLevelVariableDeclaration declaration = unit.declarations[1];
FunctionExpression function =
declaration.variables.variables[0].initializer;
@@ -3010,9 +2868,9 @@ var Y = () {
var V = [42];
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT9);
- expect(outputs[RESOLVED_UNIT9], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT9], isTrue);
+ computeResult(target, RESOLVED_UNIT8);
+ expect(outputs[RESOLVED_UNIT8], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT8], isTrue);
// An INFERRED_TYPE_LITERAL error should be generated.
List<AnalysisError> errors = outputs[
STATIC_VARIABLE_RESOLUTION_ERRORS_IN_UNIT] as List<AnalysisError>;
@@ -3425,36 +3283,6 @@ class B {}''');
@reflectiveTest
class PartiallyResolveUnitReferencesTaskTest extends _AbstractDartTaskTest {
- test_perform_propagable() {
- enableStrongMode();
- Source source = newSource(
- '/test.dart',
- '''
-const t1 = 1;
-final t2 = 2;
-var t3 = 3;
-final t4;
-class C {
- static const fs1 = 1;
- static final fs2 = 2;
- static var fs3 = 3;
- static final fs4;
- const fi1 = 1;
- final fi2 = 2;
- var fi3 = 3;
- final fi4;
-}
-''');
- LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, PROPAGABLE_VARIABLES_IN_UNIT,
- matcher: isPartiallyResolveUnitReferencesTask);
- // PROPAGABLE_VARIABLES_IN_UNIT
- List<VariableElement> variables =
- outputs[PROPAGABLE_VARIABLES_IN_UNIT] as List<VariableElement>;
- expect(variables.map((v) => v.displayName),
- unorderedEquals(['t1', 't2', 'fs1', 'fs2', 'fi1', 'fi2']));
- }
-
test_perform_strong_importExport() {
newSource(
'/a.dart',
@@ -3597,138 +3425,6 @@ class C {
}
@reflectiveTest
-class PropagateVariableTypesInUnitTaskTest extends _AbstractDartTaskTest {
- test_created_resolved_unit() {
- Source source = newSource(
- '/test.dart',
- r'''
-library lib;
-class A {}
-''');
- LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT8);
- expect(outputs[RESOLVED_UNIT8], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT8], isTrue);
- }
-
- void test_perform_cycle() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-final piFirst = true;
-final pi = piFirst ? 3.14 : tau / 2;
-final tau = piFirst ? pi * 2 : 6.28;
-''');
- // compute
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8,
- matcher: isPropagateVariableTypesInUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT8];
- // verify
- TopLevelVariableElement piFirst =
- AstFinder.getTopLevelVariableElement(unit, 'piFirst');
- TopLevelVariableElement pi =
- AstFinder.getTopLevelVariableElement(unit, 'pi');
- TopLevelVariableElement tau =
- AstFinder.getTopLevelVariableElement(unit, 'tau');
- expect(piFirst.propagatedType, context.typeProvider.boolType);
- expect(pi.propagatedType, isNull);
- expect(tau.propagatedType, isNull);
- }
-
- void test_perform_topLevel() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-//final a = b + c.length;
-final a = b;
-final b = 1;
-final c = '2';
-''');
- // compute
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8,
- matcher: isPropagateVariableTypesInUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT8];
- // verify
- InterfaceType intType = context.typeProvider.intType;
- InterfaceType stringType = context.typeProvider.stringType;
- expect(AstFinder.getTopLevelVariableElement(unit, 'a').propagatedType,
- intType);
- expect(AstFinder.getTopLevelVariableElement(unit, 'b').propagatedType,
- intType);
- expect(AstFinder.getTopLevelVariableElement(unit, 'c').propagatedType,
- stringType);
- }
-}
-
-@reflectiveTest
-class PropagateVariableTypeTaskTest extends _AbstractDartTaskTest {
- void test_perform_cycle() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-final piFirst = true;
-final pi = piFirst ? 3.14 : tau / 2;
-final tau = piFirst ? pi * 2 : 6.28;
-''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- TopLevelVariableElement piFirst =
- AstFinder.getTopLevelVariableElement(unit, 'piFirst');
- TopLevelVariableElement pi =
- AstFinder.getTopLevelVariableElement(unit, 'pi');
- TopLevelVariableElement tau =
- AstFinder.getTopLevelVariableElement(unit, 'tau');
- // compute
- computeResult(piFirst, PROPAGATED_VARIABLE,
- matcher: isPropagateVariableTypeTask);
- expect(piFirst.propagatedType, context.typeProvider.boolType);
- expect(pi.propagatedType, isNull);
- expect(tau.propagatedType, isNull);
- }
-
- void test_perform_null() {
- enableStrongMode();
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-var a = null;
-''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- TopLevelVariableElement a = AstFinder.getTopLevelVariableElement(unit, 'a');
- // compute
- computeResult(a, PROPAGATED_VARIABLE, matcher: isPropagateVariableTypeTask);
- expect(a.propagatedType, isNull);
- }
-
- void test_perform_topLevel() {
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-final a = b + c.length;
-final b = 1;
-final c = '2';
-''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7);
- CompilationUnit unit = outputs[RESOLVED_UNIT7];
- TopLevelVariableElement elementA =
- AstFinder.getTopLevelVariableElement(unit, 'a');
- TopLevelVariableElement elementB =
- AstFinder.getTopLevelVariableElement(unit, 'b');
- TopLevelVariableElement elementC =
- AstFinder.getTopLevelVariableElement(unit, 'c');
- // compute
- computeResult(elementA, PROPAGATED_VARIABLE,
- matcher: isPropagateVariableTypeTask);
- InterfaceType intType = context.typeProvider.intType;
- InterfaceType stringType = context.typeProvider.stringType;
- expect(elementA.propagatedType, intType);
- expect(elementB.propagatedType, intType);
- expect(elementC.propagatedType, stringType);
- }
-}
-
-@reflectiveTest
class ReferencedNamesBuilderTest extends _AbstractDartTaskTest {
void setUp() {
super.setUp();
@@ -4257,9 +3953,9 @@ library lib;
class A {}
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT10);
- expect(outputs[RESOLVED_UNIT10], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT10], isTrue);
+ computeResult(target, RESOLVED_UNIT9);
+ expect(outputs[RESOLVED_UNIT9], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT9], isTrue);
}
// Test inference of instance fields across units
@@ -4289,16 +3985,16 @@ class A {}
DartType dynamicType = context.typeProvider.dynamicType;
computeResult(
- new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT10);
- CompilationUnit unit1 = outputs[RESOLVED_UNIT10];
+ new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT9);
+ CompilationUnit unit1 = outputs[RESOLVED_UNIT9];
// B.b2 shoud be resolved on the rhs, but not yet inferred.
assertVariableDeclarationTypes(
AstFinder.getFieldInClass(unit1, "B", "b2"), dynamicType, intType);
computeResult(
- new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10);
- CompilationUnit unit0 = outputs[RESOLVED_UNIT10];
+ new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9);
+ CompilationUnit unit0 = outputs[RESOLVED_UNIT9];
// B.b2 should now be fully resolved and inferred.
assertVariableDeclarationTypes(
@@ -4309,7 +4005,7 @@ class A {}
AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, intType);
computeResult(
- new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT10);
+ new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT9);
// A.a2 should now be fully resolved and inferred.
assertVariableDeclarationTypes(
@@ -4346,15 +4042,15 @@ class A {}
DartType dynamicType = context.typeProvider.dynamicType;
computeResult(
- new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10);
- CompilationUnit unit0 = outputs[RESOLVED_UNIT10];
+ new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9);
+ CompilationUnit unit0 = outputs[RESOLVED_UNIT9];
// A.a2 should now be resolved on the rhs, but not yet inferred.
assertVariableDeclarationTypes(
AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType);
computeResult(
- new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT10);
+ new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT9);
// A.a2 should now be fully resolved and inferred (but not re-resolved).
assertVariableDeclarationTypes(
@@ -4392,8 +4088,8 @@ class A {}
DartType dynamicType = context.typeProvider.dynamicType;
computeResult(
- new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT10);
- CompilationUnit unit1 = outputs[RESOLVED_UNIT10];
+ new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT9);
+ CompilationUnit unit1 = outputs[RESOLVED_UNIT9];
assertVariableDeclarationTypes(
AstFinder.getFieldInClass(unit1, "B", "b1"), intType, intType);
@@ -4401,8 +4097,8 @@ class A {}
AstFinder.getFieldInClass(unit1, "B", "b2"), dynamicType, intType);
computeResult(
- new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10);
- CompilationUnit unit0 = outputs[RESOLVED_UNIT10];
+ new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9);
+ CompilationUnit unit0 = outputs[RESOLVED_UNIT9];
assertVariableDeclarationTypes(
AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType);
@@ -4415,7 +4111,7 @@ class A {}
AstFinder.getFieldInClass(unit1, "B", "b2"), intType, intType);
computeResult(
- new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT10);
+ new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT9);
assertVariableDeclarationTypes(
AstFinder.getFieldInClass(unit0, "A", "a1"), intType, intType);
@@ -4454,8 +4150,8 @@ class A {}
DartType dynamicType = context.typeProvider.dynamicType;
computeResult(
- new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT10);
- CompilationUnit unit0 = outputs[RESOLVED_UNIT10];
+ new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT9);
+ CompilationUnit unit0 = outputs[RESOLVED_UNIT9];
// A.a2 should now be resolved on the rhs, but not yet inferred.
assertVariableDeclarationTypes(
@@ -4466,7 +4162,7 @@ class A {}
AstFinder.getFieldInClass(unit0, "B", "b2"), dynamicType, intType);
computeResult(
- new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT10);
+ new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT9);
// A.a2 should now be fully resolved and inferred (but not re-resolved).
assertVariableDeclarationTypes(
@@ -4703,9 +4399,9 @@ library lib;
class A {}
''');
LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
- computeResult(target, RESOLVED_UNIT12);
- expect(outputs[RESOLVED_UNIT12], isNotNull);
- expect(outputs[CREATED_RESOLVED_UNIT12], isTrue);
+ computeResult(target, RESOLVED_UNIT11);
+ expect(outputs[RESOLVED_UNIT11], isNotNull);
+ expect(outputs[CREATED_RESOLVED_UNIT11], isTrue);
}
void test_perform() {
@@ -4722,9 +4418,9 @@ class C {
}
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12,
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11,
matcher: isResolveUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
FunctionDeclaration f = unit.declarations[0];
_assertResolved(f.functionExpression.body);
@@ -4735,33 +4431,6 @@ class C {
expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0));
}
- void test_perform_ensurePropagatedVariableTypes() {
- newSource(
- '/lib.dart',
- '''
-class A {
- final v = 1;
-}
-''');
- AnalysisTarget source = newSource(
- '/test.dart',
- '''
-import 'lib.dart';
-main(A a) {
- a.v.isEven;
-}
-''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12,
- matcher: isResolveUnitTask);
- expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0));
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
- FunctionDeclaration main = unit.declarations[0];
- BlockFunctionBody body = main.functionExpression.body;
- ExpressionStatement statement = body.block.statements.single;
- Expression expression = statement.expression;
- expect(expression.bestType, context.typeProvider.boolType);
- }
-
void _assertResolved(FunctionBody body) {
ResolutionVerifier verifier = new ResolutionVerifier();
body.accept(verifier);
@@ -5056,8 +4725,8 @@ var piFirst = true;
var pi = piFirst ? 3.14 : tau / 2;
var tau = piFirst ? pi * 2 : 6.28;
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
VariableElement piFirst =
AstFinder.getTopLevelVariable(unit, 'piFirst').name.staticElement;
VariableElement pi =
@@ -5099,11 +4768,11 @@ var tau = piFirst ? pi * 2 : 6.28;
}
''');
computeResult(
- new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT12);
- CompilationUnit unit1 = outputs[RESOLVED_UNIT12];
+ new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT11);
+ CompilationUnit unit1 = outputs[RESOLVED_UNIT11];
computeResult(
- new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT12);
- CompilationUnit unit2 = outputs[RESOLVED_UNIT12];
+ new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT11);
+ CompilationUnit unit2 = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
@@ -5150,7 +4819,7 @@ var tau = piFirst ? pi * 2 : 6.28;
'''
});
List<dynamic> units =
- computeLibraryResults(sources, RESOLVED_UNIT12).toList();
+ computeLibraryResults(sources, RESOLVED_UNIT11).toList();
CompilationUnit unit0 = units[0];
CompilationUnit unit1 = units[1];
CompilationUnit unit2 = units[2];
@@ -5197,7 +4866,7 @@ var tau = piFirst ? pi * 2 : 6.28;
'''
});
List<dynamic> units =
- computeLibraryResults(sources, RESOLVED_UNIT12).toList();
+ computeLibraryResults(sources, RESOLVED_UNIT11).toList();
CompilationUnit unit0 = units[0];
CompilationUnit unit2 = units[2];
@@ -5238,11 +4907,11 @@ var tau = piFirst ? pi * 2 : 6.28;
}
''');
computeResult(
- new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT12);
- CompilationUnit unit1 = outputs[RESOLVED_UNIT12];
+ new LibrarySpecificUnit(firstSource, firstSource), RESOLVED_UNIT11);
+ CompilationUnit unit1 = outputs[RESOLVED_UNIT11];
computeResult(
- new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT12);
- CompilationUnit unit2 = outputs[RESOLVED_UNIT12];
+ new LibrarySpecificUnit(secondSource, secondSource), RESOLVED_UNIT11);
+ CompilationUnit unit2 = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
InterfaceType stringType = context.typeProvider.stringType;
@@ -5292,7 +4961,7 @@ var tau = piFirst ? pi * 2 : 6.28;
'''
});
List<dynamic> units =
- computeLibraryResults(sources, RESOLVED_UNIT12).toList();
+ computeLibraryResults(sources, RESOLVED_UNIT11).toList();
CompilationUnit unit0 = units[0];
CompilationUnit unit1 = units[1];
CompilationUnit unit2 = units[2];
@@ -5328,8 +4997,8 @@ var tau = piFirst ? pi * 2 : 6.28;
y = "hi";
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
InterfaceType stringType = context.typeProvider.stringType;
@@ -5367,8 +5036,8 @@ var tau = piFirst ? pi * 2 : 6.28;
final z = 42; // should infer `int`
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
InterfaceType stringType = context.typeProvider.stringType;
@@ -5416,8 +5085,8 @@ var tau = piFirst ? pi * 2 : 6.28;
int y = 0; // field def after use
final z = 42; // should infer `int`
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
InterfaceType stringType = context.typeProvider.stringType;
@@ -5469,8 +5138,8 @@ var tau = piFirst ? pi * 2 : 6.28;
new A().y2 = /*severe:StaticTypeError*/"hi";
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
InterfaceType stringType = context.typeProvider.stringType;
@@ -5511,8 +5180,8 @@ var tau = piFirst ? pi * 2 : 6.28;
x = "hi";
}
''');
- computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
- CompilationUnit unit = outputs[RESOLVED_UNIT12];
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT11);
+ CompilationUnit unit = outputs[RESOLVED_UNIT11];
InterfaceType intType = context.typeProvider.intType;
InterfaceType stringType = context.typeProvider.stringType;
« no previous file with comments | « pkg/analyzer/test/src/summary/summary_common.dart ('k') | pkg/analyzer/tool/task_dependency_graph/tasks.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698