Remove useOldFrontend testing from TypeEnvironment
Change-Id: I0d62b83073ce5c7008f85c0c32b74c9b70cc4eb0
Reviewed-on: https://dart-review.googlesource.com/53960
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/ordered_typeset.dart b/pkg/compiler/lib/src/ordered_typeset.dart
index 860d67f..52b4d61 100644
--- a/pkg/compiler/lib/src/ordered_typeset.dart
+++ b/pkg/compiler/lib/src/ordered_typeset.dart
@@ -36,8 +36,7 @@
final Link<InterfaceType> types;
final Link<InterfaceType> _supertypes;
- OrderedTypeSet.internal(List<Link<InterfaceType>> this._levels,
- Link<InterfaceType> this.types, Link<InterfaceType> this._supertypes);
+ OrderedTypeSet.internal(this._levels, this.types, this._supertypes);
factory OrderedTypeSet.singleton(InterfaceType type) {
Link<InterfaceType> types =
diff --git a/tests/compiler/dart2js/inference/type_mask2_test.dart b/tests/compiler/dart2js/inference/type_mask2_test.dart
index a3c40a0..b3c5100 100644
--- a/tests/compiler/dart2js/inference/type_mask2_test.dart
+++ b/tests/compiler/dart2js/inference/type_mask2_test.dart
@@ -24,16 +24,14 @@
}
void main() {
- runTests({bool useOldFrontend}) async {
- await testUnionTypeMaskFlatten(useOldFrontend: useOldFrontend);
- await testStringSubtypes(useOldFrontend: useOldFrontend);
+ runTests() async {
+ await testUnionTypeMaskFlatten();
+ await testStringSubtypes();
}
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await runTests(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await runTests(useOldFrontend: false);
+ await runTests();
});
}
@@ -92,7 +90,7 @@
return union;
}
-Future testUnionTypeMaskFlatten({bool useOldFrontend}) async {
+Future testUnionTypeMaskFlatten() async {
TypeEnvironment env = await TypeEnvironment.create(r"""
class A {}
class B {}
@@ -107,7 +105,7 @@
new D();
new E();
}
- """, useOldFrontend: useOldFrontend);
+ """);
ClosedWorld closedWorld = env.closedWorld;
@@ -211,13 +209,11 @@
}
Future testStringSubtypes({bool useOldFrontend}) async {
- TypeEnvironment env = await TypeEnvironment.create('',
- mainSource: r"""
+ TypeEnvironment env = await TypeEnvironment.create('', mainSource: r"""
main() {
'' is String;
}
- """,
- useOldFrontend: useOldFrontend);
+ """);
ClosedWorld closedWorld = env.closedWorld;
ClassEntity Object_ = env.getElement("Object");
diff --git a/tests/compiler/dart2js/inference/union_type_test.dart b/tests/compiler/dart2js/inference/union_type_test.dart
index 39166f6..1890622 100644
--- a/tests/compiler/dart2js/inference/union_type_test.dart
+++ b/tests/compiler/dart2js/inference/union_type_test.dart
@@ -9,7 +9,7 @@
import '../type_test_helper.dart';
main() {
- runTest({bool useOldFrontend}) async {
+ runTest() async {
TypeEnvironment env = await TypeEnvironment.create(r"""
class A {}
class B {}
@@ -18,7 +18,7 @@
new A();
new B();
}
- """, useOldFrontend: useOldFrontend);
+ """);
ClosedWorld world = env.closedWorld;
FlatTypeMask mask1 = new FlatTypeMask.exact(env.getClass('A'));
FlatTypeMask mask2 = new FlatTypeMask.exact(env.getClass('B'));
@@ -28,9 +28,7 @@
}
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await runTest(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await runTest(useOldFrontend: false);
+ await runTest();
});
}
diff --git a/tests/compiler/dart2js/instantiated_classes_test.dart b/tests/compiler/dart2js/instantiated_classes_test.dart
index 7c10a5d9..4c1aab1 100644
--- a/tests/compiler/dart2js/instantiated_classes_test.dart
+++ b/tests/compiler/dart2js/instantiated_classes_test.dart
@@ -12,7 +12,7 @@
import 'type_test_helper.dart';
void main() {
- Future runTests({bool useKernel}) async {
+ Future runTests() async {
Future test(String source, List<String> directlyInstantiatedClasses,
[List<String> newClasses = const <String>["Class"]]) async {
StringBuffer mainSource = new StringBuffer();
@@ -22,7 +22,7 @@
}
mainSource.write('}');
dynamic env = await TypeEnvironment.create(source,
- mainSource: mainSource.toString(), useOldFrontend: !useKernel);
+ mainSource: mainSource.toString());
LibraryEntity mainLibrary =
env.compiler.frontendStrategy.elementEnvironment.mainLibrary;
Iterable<ClassEntity> expectedClasses =
@@ -69,24 +69,14 @@
class Class extends B with A {}""", ["Class", "A"],
["Class", "A"]);
- if (!useKernel) {
- // TODO(johnniwinther): Avoid registration of `Class` as instantiated.
- await test("""class A {}
- class Class implements A {
- factory Class() = A;
- }""", ["Class", "A"], ["Class"]);
- } else {
- await test("""class A {}
- class Class implements A {
- factory Class() = A;
- }""", ["A"], ["Class"]);
- }
+ await test("""class A {}
+ class Class implements A {
+ factory Class() = A;
+ }""", ["A"], ["Class"]);
}
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await runTests(useKernel: false);
print('--test from kernel------------------------------------------------');
- await runTests(useKernel: true);
+ await runTests();
});
}
diff --git a/tests/compiler/dart2js/model/class_set_test.dart b/tests/compiler/dart2js/model/class_set_test.dart
index 0740ead..a8216b1 100644
--- a/tests/compiler/dart2js/model/class_set_test.dart
+++ b/tests/compiler/dart2js/model/class_set_test.dart
@@ -18,22 +18,20 @@
void main() {
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await testAll(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await testAll(useOldFrontend: false);
+ await testAll();
print('--test from kernel (strong)---------------------------------------');
- await testAll(useOldFrontend: false, strongMode: true);
+ await testAll(strongMode: true);
});
}
-testAll({bool useOldFrontend, bool strongMode: false}) async {
- await testIterators(useOldFrontend: useOldFrontend);
- await testForEach(useOldFrontend: useOldFrontend);
- await testClosures(useOldFrontend: useOldFrontend, strongMode: strongMode);
+testAll({bool strongMode: false}) async {
+ await testIterators();
+ await testForEach();
+ await testClosures(strongMode: strongMode);
}
-testIterators({bool useOldFrontend}) async {
+testIterators() async {
var env = await TypeEnvironment.create(r"""
/// A
/// / \
@@ -57,7 +55,7 @@
new F();
new G();
}
- """, useOldFrontend: useOldFrontend);
+ """);
ClosedWorld world = env.closedWorld;
ClassEntity A = env.getClass("A");
@@ -356,7 +354,7 @@
Expect.isNull(iterator.current);
}
-testForEach({bool useOldFrontend}) async {
+testForEach() async {
var env = await TypeEnvironment.create(r"""
/// A
/// / \
@@ -387,7 +385,7 @@
new H();
new I();
}
- """, useOldFrontend: useOldFrontend);
+ """);
ClosedWorld world = env.closedWorld;
ClassEntity A = env.getClass("A");
@@ -590,7 +588,7 @@
find: I, anySubtype: true, expectedResult: true);
}
-testClosures({bool useOldFrontend, bool strongMode}) async {
+testClosures({bool strongMode}) async {
var env = await TypeEnvironment.create(r"""
class A {
call() => null;
@@ -603,7 +601,6 @@
local() {}
}
""",
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [],
testBackendWorld: true);
ClosedWorld world = env.closedWorld;
diff --git a/tests/compiler/dart2js/model/constant_value_test.dart b/tests/compiler/dart2js/model/constant_value_test.dart
index 3a5d4fb..5d0aa37 100644
--- a/tests/compiler/dart2js/model/constant_value_test.dart
+++ b/tests/compiler/dart2js/model/constant_value_test.dart
@@ -7,7 +7,8 @@
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
import 'package:compiler/src/helpers/helpers.dart';
-import 'package:compiler/src/elements/elements.dart';
+import 'package:compiler/src/elements/entities.dart';
+import 'package:compiler/src/elements/types.dart';
import 'package:compiler/src/constants/values.dart';
import '../type_test_helper.dart';
@@ -22,15 +23,16 @@
C(this.field1, this.field2);
}
- ''', useOldFrontend: true);
- ClassElement C = env.getElement('C');
- FieldElement field1 = C.lookupLocalMember('field1');
- FieldElement field2 = C.lookupLocalMember('field2');
- ConstantValue value1 = new ConstructedConstantValue(C.rawType, {
+ ''');
+ ClassEntity C = env.getClass('C');
+ InterfaceType C_raw = env.elementEnvironment.getRawType(C);
+ FieldEntity field1 = env.elementEnvironment.lookupClassMember(C, 'field1');
+ FieldEntity field2 = env.elementEnvironment.lookupClassMember(C, 'field2');
+ ConstructedConstantValue value1 = new ConstructedConstantValue(C_raw, {
field1: new IntConstantValue(0),
field2: new IntConstantValue(1),
});
- ConstantValue value2 = new ConstructedConstantValue(C.rawType, {
+ ConstantValue value2 = new ConstructedConstantValue(C_raw, {
field2: new IntConstantValue(1),
field1: new IntConstantValue(0),
});
diff --git a/tests/compiler/dart2js/model/mixin_typevariable_test.dart b/tests/compiler/dart2js/model/mixin_typevariable_test.dart
index cf8a6d8..ff9a9ec 100644
--- a/tests/compiler/dart2js/model/mixin_typevariable_test.dart
+++ b/tests/compiler/dart2js/model/mixin_typevariable_test.dart
@@ -5,18 +5,20 @@
library mixin_typevariable_test;
import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import 'package:compiler/src/elements/elements.dart' show ClassElement;
+import 'package:compiler/src/elements/entities.dart';
+import 'package:compiler/src/elements/types.dart';
import 'package:expect/expect.dart';
import '../type_test_helper.dart';
void main() {
- testMixinSupertypes();
- testNonTrivialSubstitutions();
+ asyncTest(() async {
+ await testMixinSupertypes();
+ await testNonTrivialSubstitutions();
+ });
}
-void testMixinSupertypes() {
- asyncTest(() => TypeEnvironment.create(r"""
+testMixinSupertypes() async {
+ var env = await TypeEnvironment.create(r"""
class S<S_T> {}
class M1<M1_T> {}
class M2<M2_T> {}
@@ -24,54 +26,54 @@
class C1<C1_T> extends S<C1_T> with M1<C1_T>, M2<C1_T>, M3<C1_T> {}
class C2<C2_T> = S<C2_T> with M1<C2_T>, M2<C2_T>, M3<C2_T>;
- """, expectNoWarningsOrErrors: true, useOldFrontend: true).then((env) {
- ClassElement Object = env.getElement('Object');
- ClassElement S = env.getElement('S');
- ClassElement M1 = env.getElement('M1');
- ClassElement M2 = env.getElement('M2');
- ClassElement C1 = env.getElement('C1');
- ClassElement C2 = env.getElement('C2');
+ """, expectNoWarningsOrErrors: true);
+ ClassEntity Object = env.getElement('Object');
+ ClassEntity S = env.getClass('S');
+ ClassEntity M1 = env.getClass('M1');
+ ClassEntity M2 = env.getClass('M2');
+ ClassEntity C1 = env.getClass('C1');
+ ClassEntity C2 = env.getClass('C2');
- ClassElement C1_S_M1_M2_M3 = C1.superclass;
- ClassElement C1_S_M1_M2 = C1_S_M1_M2_M3.superclass;
- ClassElement C1_S_M1 = C1_S_M1_M2.superclass;
+ ClassEntity C1_S_M1_M2_M3 = env.elementEnvironment.getSuperClass(C1);
+ ClassEntity C1_S_M1_M2 = env.elementEnvironment.getSuperClass(C1_S_M1_M2_M3);
+ ClassEntity C1_S_M1 = env.elementEnvironment.getSuperClass(C1_S_M1_M2);
- ClassElement C2_S_M1_M2 = C2.superclass;
- ClassElement C2_S_M1 = C2_S_M1_M2.superclass;
+ ClassEntity C2_S_M1_M2 = env.elementEnvironment.getSuperClass(C2);
+ ClassEntity C2_S_M1 = env.elementEnvironment.getSuperClass(C2_S_M1_M2);
- void testSupertypes(ClassElement element) {
- if (element != Object) {
- Expect.isTrue(element.typeVariables.length == 1);
- Expect.equals(
- element, element.typeVariables.first.element.enclosingElement);
- }
- for (ResolutionInterfaceType supertype
- in element.allSupertypesAndSelf.types) {
- if (!supertype.typeArguments.isEmpty) {
- Expect.listEquals(element.typeVariables, supertype.typeArguments,
- "Type argument mismatch on supertype $supertype of $element.");
- } else {
- Expect.equals(Object, supertype.element);
- }
- }
- }
+ void testSupertypes(ClassEntity element) {
+ List<DartType> typeVariables = const <DartType>[];
+ if (element != Object) {
+ typeVariables = env.elementEnvironment.getThisType(element).typeArguments;
+ Expect.isTrue(typeVariables.length == 1);
+ TypeVariableType typeVariable = typeVariables.first;
+ Expect.equals(element, typeVariable.element.typeDeclaration);
+ }
+ env.elementEnvironment.forEachSupertype(element, (InterfaceType supertype) {
+ if (!supertype.typeArguments.isEmpty) {
+ Expect.listEquals(typeVariables, supertype.typeArguments,
+ "Type argument mismatch on supertype $supertype of $element.");
+ } else {
+ Expect.equals(Object, supertype.element);
+ }
+ });
+ }
- testSupertypes(Object);
- testSupertypes(S);
- testSupertypes(M1);
- testSupertypes(M2);
- testSupertypes(C1_S_M1);
- testSupertypes(C1_S_M1_M2);
- testSupertypes(C1_S_M1_M2_M3);
- testSupertypes(C1);
- testSupertypes(C2_S_M1);
- testSupertypes(C2_S_M1_M2);
- testSupertypes(C2);
- }));
+ testSupertypes(Object);
+ testSupertypes(S);
+ testSupertypes(M1);
+ testSupertypes(M2);
+ testSupertypes(C1_S_M1);
+ testSupertypes(C1_S_M1_M2);
+ testSupertypes(C1_S_M1_M2_M3);
+ testSupertypes(C1);
+ testSupertypes(C2_S_M1);
+ testSupertypes(C2_S_M1_M2);
+ testSupertypes(C2);
}
-void testNonTrivialSubstitutions() {
- asyncTest(() => TypeEnvironment.create(r"""
+testNonTrivialSubstitutions() async {
+ var env = await TypeEnvironment.create(r"""
class _ {}
class A<A_T> {}
class B<B_T, B_S> {}
@@ -87,128 +89,149 @@
class F1<F1_T> extends A<_> with B<_, B<F1_T, _>> {}
class F2<F2_T> = A<_> with B<_, B<F2_T, _>>;
- """, expectNoWarningsOrErrors: true, useOldFrontend: true).then((env) {
- ResolutionDartType _dynamic = env['dynamic'];
- ResolutionDartType _ = env['_'];
+ """, expectNoWarningsOrErrors: true);
+ DartType _dynamic = env['dynamic'];
+ DartType _ = env['_'];
- ClassElement Object = env.getElement('Object');
- ClassElement A = env.getElement('A');
- ClassElement B = env.getElement('B');
- ClassElement C1 = env.getElement('C1');
- ClassElement C2 = env.getElement('C2');
- ClassElement D1 = env.getElement('D1');
- ClassElement D2 = env.getElement('D2');
- ClassElement E1 = env.getElement('E1');
- ClassElement E2 = env.getElement('E2');
- ClassElement F1 = env.getElement('F1');
- ClassElement F2 = env.getElement('F2');
+ ClassEntity Object = env.getElement('Object');
+ ClassEntity A = env.getClass('A');
+ ClassEntity B = env.getClass('B');
+ ClassEntity C1 = env.getClass('C1');
+ ClassEntity C2 = env.getClass('C2');
+ ClassEntity D1 = env.getClass('D1');
+ ClassEntity D2 = env.getClass('D2');
+ ClassEntity E1 = env.getClass('E1');
+ ClassEntity E2 = env.getClass('E2');
+ ClassEntity F1 = env.getClass('F1');
+ ClassEntity F2 = env.getClass('F2');
- void testSupertypes(ClassElement element,
- Map<ClassElement, List<ResolutionDartType>> typeArguments) {
- if (element != Object) {
- Expect.isTrue(element.typeVariables.length == 1);
- Expect.equals(
- element, element.typeVariables.first.element.enclosingElement);
- }
- for (ResolutionInterfaceType supertype
- in element.allSupertypesAndSelf.types) {
- if (typeArguments.containsKey(supertype.element)) {
- Expect.listEquals(
- typeArguments[supertype.element],
- supertype.typeArguments,
- "Type argument mismatch on supertype $supertype of $element.");
- } else if (!supertype.typeArguments.isEmpty) {
- Expect.listEquals(element.typeVariables, supertype.typeArguments,
- "Type argument mismatch on supertype $supertype of $element.");
- } else {
- Expect.equals(Object, supertype.element);
- }
- }
- }
+ void testSupertypes(
+ ClassEntity element, Map<ClassEntity, List<DartType>> typeArguments) {
+ List<DartType> typeVariables = const <DartType>[];
+ if (element != Object) {
+ typeVariables = env.elementEnvironment.getThisType(element).typeArguments;
+ if (env.elementEnvironment.isUnnamedMixinApplication(element)) {
+ // Kernel doesn't add type variables to unnamed mixin applications when
+ // these aren't need for its supertypes.
+ Expect.isTrue(typeVariables.length <= 1);
+ } else {
+ Expect.isTrue(typeVariables.length == 1);
+ }
+ if (typeVariables.isNotEmpty) {
+ TypeVariableType typeVariable = typeVariables.first;
+ Expect.equals(element, typeVariable.element.typeDeclaration);
+ }
+ }
+ env.elementEnvironment.forEachSupertype(element, (InterfaceType supertype) {
+ if (typeArguments.containsKey(supertype.element)) {
+ Expect.listEquals(
+ typeArguments[supertype.element],
+ supertype.typeArguments,
+ "Type argument mismatch on supertype $supertype of $element.");
+ } else if (!supertype.typeArguments.isEmpty) {
+ Expect.listEquals(typeVariables, supertype.typeArguments,
+ "Type argument mismatch on supertype $supertype of $element.");
+ } else if (env.elementEnvironment
+ .isUnnamedMixinApplication(supertype.element)) {
+ // Kernel doesn't add type variables to unnamed mixin applications when
+ // these aren't need for its supertypes.
+ Expect.isTrue(supertype.typeArguments.isEmpty,
+ "Type argument mismatch on supertype $supertype of $element.");
+ } else {
+ Expect.equals(Object, supertype.element,
+ "Type argument mismatch on supertype $supertype of $element.");
+ }
+ });
+ }
- testSupertypes(C1, {
- A: [_dynamic],
- B: [_dynamic, _dynamic]
- });
- testSupertypes(C1.superclass, {
- A: [_dynamic],
- B: [_dynamic, _dynamic]
- });
- testSupertypes(C2, {
- A: [_dynamic],
- B: [_dynamic, _dynamic]
- });
+ testSupertypes(C1, {
+ A: [_dynamic],
+ B: [_dynamic, _dynamic]
+ });
+ testSupertypes(env.elementEnvironment.getSuperClass(C1), {
+ A: [_dynamic],
+ B: [_dynamic, _dynamic]
+ });
+ testSupertypes(C2, {
+ A: [_dynamic],
+ B: [_dynamic, _dynamic]
+ });
- ResolutionDartType D1_T = D1.typeVariables.first;
- testSupertypes(D1, {
- A: [D1_T],
- B: [
- D1_T,
- instantiate(A, [D1_T])
- ]
- });
- ResolutionDartType D1_superclass_T = D1.superclass.typeVariables.first;
- testSupertypes(D1.superclass, {
- A: [D1_superclass_T],
- B: [
- D1_superclass_T,
- instantiate(A, [D1_superclass_T])
- ]
- });
- ResolutionDartType D2_T = D2.typeVariables.first;
- testSupertypes(D2, {
- A: [D2_T],
- B: [
- D2_T,
- instantiate(A, [D2_T])
- ]
- });
+ DartType D1_T = env.elementEnvironment.getThisType(D1).typeArguments.first;
+ testSupertypes(D1, {
+ A: [D1_T],
+ B: [
+ D1_T,
+ instantiate(A, [D1_T])
+ ]
+ });
+ DartType D1_superclass_T = env.elementEnvironment
+ .getThisType(env.elementEnvironment.getSuperClass(D1))
+ .typeArguments
+ .first;
+ testSupertypes(env.elementEnvironment.getSuperClass(D1), {
+ A: [D1_superclass_T],
+ B: [
+ D1_superclass_T,
+ instantiate(A, [D1_superclass_T])
+ ]
+ });
+ DartType D2_T = env.elementEnvironment.getThisType(D2).typeArguments.first;
+ testSupertypes(D2, {
+ A: [D2_T],
+ B: [
+ D2_T,
+ instantiate(A, [D2_T])
+ ]
+ });
- testSupertypes(E1, {
- A: [_],
- B: [
- _,
- instantiate(A, [_])
- ]
- });
- testSupertypes(E1.superclass, {
- A: [_],
- B: [
- _,
- instantiate(A, [_])
- ]
- });
- testSupertypes(E2, {
- A: [_],
- B: [
- _,
- instantiate(A, [_])
- ]
- });
+ testSupertypes(E1, {
+ A: [_],
+ B: [
+ _,
+ instantiate(A, [_])
+ ]
+ });
+ testSupertypes(env.elementEnvironment.getSuperClass(E1), {
+ A: [_],
+ B: [
+ _,
+ instantiate(A, [_])
+ ]
+ });
+ testSupertypes(E2, {
+ A: [_],
+ B: [
+ _,
+ instantiate(A, [_])
+ ]
+ });
- ResolutionDartType F1_T = F1.typeVariables.first;
- testSupertypes(F1, {
- A: [_],
- B: [
- _,
- instantiate(B, [F1_T, _])
- ]
- });
- ResolutionDartType F1_superclass_T = F1.superclass.typeVariables.first;
- testSupertypes(F1.superclass, {
- A: [_],
- B: [
- _,
- instantiate(B, [F1_superclass_T, _])
- ]
- });
- ResolutionDartType F2_T = F2.typeVariables.first;
- testSupertypes(F2, {
- A: [_],
- B: [
- _,
- instantiate(B, [F2_T, _])
- ]
- });
- }));
+ DartType F1_T = env.elementEnvironment.getThisType(F1).typeArguments.first;
+ testSupertypes(F1, {
+ A: [_],
+ B: [
+ _,
+ instantiate(B, [F1_T, _])
+ ]
+ });
+ DartType F1_superclass_T = env.elementEnvironment
+ .getThisType(env.elementEnvironment.getSuperClass(F1))
+ .typeArguments
+ .first;
+ testSupertypes(env.elementEnvironment.getSuperClass(F1), {
+ A: [_],
+ B: [
+ _,
+ instantiate(B, [F1_superclass_T, _])
+ ]
+ });
+ DartType F2_T = env.elementEnvironment.getThisType(F2).typeArguments.first;
+ testSupertypes(F2, {
+ A: [_],
+ B: [
+ _,
+ instantiate(B, [F2_T, _])
+ ]
+ });
}
diff --git a/tests/compiler/dart2js/model/subtype_test.dart b/tests/compiler/dart2js/model/subtype_test.dart
index b1dcbfd..a0704fb 100644
--- a/tests/compiler/dart2js/model/subtype_test.dart
+++ b/tests/compiler/dart2js/model/subtype_test.dart
@@ -15,36 +15,24 @@
void main() {
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await runTests(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await runTests(useOldFrontend: false);
+ await runTests();
print('--test from kernel (strong)---------------------------------------');
- await runTests(useOldFrontend: false, strongMode: true);
+ await runTests(strongMode: true);
});
}
-Future runTests({bool useOldFrontend, bool strongMode: false}) async {
- await testCallableSubtype(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testInterfaceSubtype(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testFunctionSubtyping(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testTypedefSubtyping(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testFunctionSubtypingOptional(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testTypedefSubtypingOptional(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testFunctionSubtypingNamed(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testTypedefSubtypingNamed(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testTypeVariableSubtype(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
- await testStrongModeSubtyping(
- useOldFrontend: useOldFrontend, strongMode: strongMode);
+Future runTests({bool strongMode: false}) async {
+ await testCallableSubtype(strongMode: strongMode);
+ await testInterfaceSubtype(strongMode: strongMode);
+ await testFunctionSubtyping(strongMode: strongMode);
+ await testTypedefSubtyping(strongMode: strongMode);
+ await testFunctionSubtypingOptional(strongMode: strongMode);
+ await testTypedefSubtypingOptional(strongMode: strongMode);
+ await testFunctionSubtypingNamed(strongMode: strongMode);
+ await testTypedefSubtypingNamed(strongMode: strongMode);
+ await testTypeVariableSubtype(strongMode: strongMode);
+ await testStrongModeSubtyping(strongMode: strongMode);
}
void testTypes(TypeEnvironment env, DartType subtype, DartType supertype,
@@ -69,16 +57,14 @@
testTypes(env, subtype, supertype, expectSubtype, expectMoreSpecific);
}
-Future testInterfaceSubtype({bool useOldFrontend, bool strongMode}) async {
+Future testInterfaceSubtype({bool strongMode}) async {
await TypeEnvironment.create(r"""
class A<T> {}
class B<T1, T2> extends A<T1> {}
// TODO(johnniwinther): Inheritance with different type arguments is
// currently not supported by the implementation.
class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {}
- """,
- useOldFrontend: useOldFrontend,
- options: strongMode ? [Flags.strongMode] : []).then((env) {
+ """, options: strongMode ? [Flags.strongMode] : []).then((env) {
void expect(bool expectSubtype, DartType T, DartType S,
{bool expectMoreSpecific}) {
testTypes(env, T, S, expectSubtype, expectMoreSpecific);
@@ -316,7 +302,7 @@
});
}
-Future testCallableSubtype({bool useOldFrontend, bool strongMode}) async {
+Future testCallableSubtype({bool strongMode}) async {
await TypeEnvironment.create(r"""
class U {}
class V extends U {}
@@ -330,9 +316,7 @@
int m4(V v, U u) => null;
void m5(V v, int i) => null;
}
- """,
- useOldFrontend: useOldFrontend,
- options: strongMode ? [Flags.strongMode] : []).then((env) {
+ """, options: strongMode ? [Flags.strongMode] : []).then((env) {
void expect(bool expectSubtype, DartType T, DartType S,
{bool expectMoreSpecific}) {
testTypes(env, T, S, expectSubtype, expectMoreSpecific);
@@ -379,18 +363,16 @@
'void', 'inline_void__int', '(void Function(int i) f)'),
];
-Future testFunctionSubtyping({bool useOldFrontend, bool strongMode}) async {
+Future testFunctionSubtyping({bool strongMode}) async {
await TypeEnvironment
.create(createMethods(functionTypesData),
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [])
.then(functionSubtypingHelper);
}
-Future testTypedefSubtyping({bool useOldFrontend, bool strongMode}) async {
+Future testTypedefSubtyping({bool strongMode}) async {
await TypeEnvironment
.create(createTypedefs(functionTypesData),
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [])
.then(functionSubtypingHelper);
}
@@ -467,20 +449,16 @@
const FunctionTypeData('void', 'void___Object_int', '([Object o, int i])'),
];
-Future testFunctionSubtypingOptional(
- {bool useOldFrontend, bool strongMode}) async {
+Future testFunctionSubtypingOptional({bool strongMode}) async {
await TypeEnvironment
.create(createMethods(optionalFunctionTypesData),
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [])
.then((env) => functionSubtypingOptionalHelper(env, strongMode));
}
-Future testTypedefSubtypingOptional(
- {bool useOldFrontend, bool strongMode}) async {
+Future testTypedefSubtypingOptional({bool strongMode}) async {
await TypeEnvironment
.create(createTypedefs(optionalFunctionTypesData),
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [])
.then((env) => functionSubtypingOptionalHelper(env, strongMode));
}
@@ -545,11 +523,9 @@
const FunctionTypeData('void', 'void___c_int', '({int c})'),
];
-Future testFunctionSubtypingNamed(
- {bool useOldFrontend, bool strongMode}) async {
+Future testFunctionSubtypingNamed({bool strongMode}) async {
await TypeEnvironment
.create(createMethods(namedFunctionTypesData),
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [])
.then((env) => functionSubtypingNamedHelper(env, strongMode));
}
@@ -557,7 +533,6 @@
Future testTypedefSubtypingNamed({bool useOldFrontend, bool strongMode}) async {
await TypeEnvironment
.create(createTypedefs(namedFunctionTypesData),
- useOldFrontend: useOldFrontend,
options: strongMode ? [Flags.strongMode] : [])
.then((env) => functionSubtypingNamedHelper(env, strongMode));
}
@@ -598,7 +573,7 @@
expect(true, 'void___a_int_b_int_c_int', 'void___c_int');
}
-Future testTypeVariableSubtype({bool useOldFrontend, bool strongMode}) async {
+Future testTypeVariableSubtype({bool strongMode}) async {
await TypeEnvironment.create(r"""
class A<T> {}
class B<T extends Object> {}
@@ -610,9 +585,7 @@
class H<T extends S, S extends T> {}
class I<T extends S, S extends U, U extends T> {}
class J<T extends S, S extends U, U extends S> {}
- """,
- useOldFrontend: useOldFrontend,
- options: strongMode ? [Flags.strongMode] : []).then((env) {
+ """, options: strongMode ? [Flags.strongMode] : []).then((env) {
void expect(bool expectSubtype, DartType T, DartType S,
{bool expectMoreSpecific}) {
testTypes(env, T, S, expectSubtype, expectMoreSpecific);
@@ -822,7 +795,7 @@
});
}
-Future testStrongModeSubtyping({bool useOldFrontend, bool strongMode}) async {
+Future testStrongModeSubtyping({bool strongMode}) async {
await TypeEnvironment.create(r"""
class ClassWithCall {
void call() {}
@@ -836,9 +809,7 @@
takeInt(int o) => null;
takeVoid(void o) => null;
takeObject(Object o) => null;
- """,
- useOldFrontend: useOldFrontend,
- options: strongMode ? [Flags.strongMode] : []).then((env) {
+ """, options: strongMode ? [Flags.strongMode] : []).then((env) {
void expect(bool expectSubtype, DartType T, DartType S) {
Expect.equals(expectSubtype, env.isSubtype(T, S), '$T <: $S');
if (expectSubtype) {
diff --git a/tests/compiler/dart2js/model/subtypeset_test.dart b/tests/compiler/dart2js/model/subtypeset_test.dart
index c31a641..af5d652 100644
--- a/tests/compiler/dart2js/model/subtypeset_test.dart
+++ b/tests/compiler/dart2js/model/subtypeset_test.dart
@@ -16,16 +16,14 @@
void main() {
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await runTests(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await runTests(useOldFrontend: false);
+ await runTests();
print('--test from kernel (strong)---------------------------------------');
- await runTests(useOldFrontend: false, strongMode: true);
+ await runTests(strongMode: true);
});
}
-runTests({bool useOldFrontend, bool strongMode: false}) async {
+runTests({bool strongMode: false}) async {
var env = await TypeEnvironment.create(r"""
/// A
/// / \
@@ -44,8 +42,7 @@
class G extends C {}
abstract class H implements C {}
abstract class I implements H {}
- """,
- mainSource: r"""
+ """, mainSource: r"""
main() {
new A().call;
new C();
@@ -54,9 +51,7 @@
new F();
new G();
}
- """,
- useOldFrontend: useOldFrontend,
- options: strongMode ? [Flags.strongMode] : []);
+ """, options: strongMode ? [Flags.strongMode] : []);
ClosedWorld world = env.closedWorld;
ClassEntity A = env.getElement("A");
diff --git a/tests/compiler/dart2js/model/type_substitution_test.dart b/tests/compiler/dart2js/model/type_substitution_test.dart
index a37de8c..a00a701 100644
--- a/tests/compiler/dart2js/model/type_substitution_test.dart
+++ b/tests/compiler/dart2js/model/type_substitution_test.dart
@@ -8,18 +8,17 @@
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
-import 'package:compiler/src/elements/resolution_types.dart';
-import '../compiler_helper.dart';
+import 'package:compiler/src/common_elements.dart';
+import 'package:compiler/src/elements/entities.dart';
+import 'package:compiler/src/elements/types.dart';
import '../type_test_helper.dart';
-ResolutionDartType getType(compiler, String name) {
- dynamic clazz = findElement(compiler, "Class");
- clazz.ensureResolved(compiler.resolution);
- dynamic element = clazz.buildScope().lookup(name);
+DartType getType(ElementEnvironment elementEnvironment, String name) {
+ ClassEntity cls =
+ elementEnvironment.lookupClass(elementEnvironment.mainLibrary, 'Class');
+ FunctionEntity element = elementEnvironment.lookupClassMember(cls, name);
Expect.isNotNull(element);
- Expect.equals(element.kind, ElementKind.FUNCTION);
- element.computeType(compiler.resolution);
- FunctionSignature signature = element.functionSignature;
+ FunctionType type = elementEnvironment.getFunctionType(element);
// Function signatures are used to be to provide void types (only occurring as
// as return types) and (inlined) function types (only occurring as method
@@ -27,69 +26,78 @@
//
// Only a single type is used from each signature. That is, it is not the
// intention to check the whole signatures against eachother.
- if (signature.requiredParameterCount == 0) {
+ if (type.parameterTypes.isEmpty) {
// If parameters is empty, use return type.
- return signature.type.returnType;
+ return type.returnType;
} else {
// Otherwise use the first argument type.
- return signature.requiredParameters.first.type;
+ return type.parameterTypes.first;
}
}
void main() {
- testAsInstanceOf();
- testTypeSubstitution();
+ asyncTest(() async {
+ await testAsInstanceOf();
+ await testTypeSubstitution();
+ });
}
-void testAsInstanceOf() {
- asyncTest(() => TypeEnvironment.create('''
+testAsInstanceOf() async {
+ var env = await TypeEnvironment.create('''
class A<T> {}
class B<T> {}
class C<T> extends A<T> {}
class D<T> extends A<int> {}
class E<T> extends A<A<T>> {}
class F<T, U> extends B<F<T, String>> implements A<F<B<U>, int>> {}
- ''', useOldFrontend: true).then((env) {
- ClassElement A = env.getElement("A");
- ClassElement B = env.getElement("B");
- ClassElement C = env.getElement("C");
- ClassElement D = env.getElement("D");
- ClassElement E = env.getElement("E");
- ClassElement F = env.getElement("F");
+ ''', mainSource: '''
+ main() {
+ new A();
+ new B();
+ new C();
+ new D();
+ new E();
+ new F();
+ }
+ ''');
+ ClassEntity A = env.getElement("A");
+ ClassEntity B = env.getElement("B");
+ ClassEntity C = env.getElement("C");
+ ClassEntity D = env.getElement("D");
+ ClassEntity E = env.getElement("E");
+ ClassEntity F = env.getElement("F");
- ResolutionDartType intType = env['int'];
- ResolutionDartType stringType = env['String'];
+ DartType intType = env['int'];
+ DartType stringType = env['String'];
- ResolutionInterfaceType C_int = instantiate(C, [intType]);
- Expect.equals(instantiate(C, [intType]), C_int);
- Expect.equals(instantiate(A, [intType]), C_int.asInstanceOf(A));
+ InterfaceType C_int = instantiate(C, [intType]);
+ Expect.equals(instantiate(C, [intType]), C_int);
+ Expect.equals(instantiate(A, [intType]), env.types.asInstanceOf(C_int, A));
- ResolutionInterfaceType D_int = instantiate(D, [stringType]);
- Expect.equals(instantiate(A, [intType]), D_int.asInstanceOf(A));
+ InterfaceType D_int = instantiate(D, [stringType]);
+ Expect.equals(instantiate(A, [intType]), env.types.asInstanceOf(D_int, A));
- ResolutionInterfaceType E_int = instantiate(E, [intType]);
- Expect.equals(
- instantiate(A, [
- instantiate(A, [intType])
- ]),
- E_int.asInstanceOf(A));
+ InterfaceType E_int = instantiate(E, [intType]);
+ Expect.equals(
+ instantiate(A, [
+ instantiate(A, [intType])
+ ]),
+ env.types.asInstanceOf(E_int, A));
- ResolutionInterfaceType F_int_string =
- instantiate(F, [intType, stringType]);
- Expect.equals(
- instantiate(B, [
- instantiate(F, [intType, stringType])
- ]),
- F_int_string.asInstanceOf(B));
- Expect.equals(
- instantiate(A, [
- instantiate(F, [
- instantiate(B, [stringType]),
- intType
- ])
- ]),
- F_int_string.asInstanceOf(A));
- }));
+ InterfaceType F_int_string = instantiate(F, [intType, stringType]);
+ Expect.equals(
+ instantiate(B, [
+ instantiate(F, [intType, stringType])
+ ]),
+ env.types.asInstanceOf(F_int_string, B));
+ Expect.equals(
+ instantiate(A, [
+ instantiate(F, [
+ instantiate(B, [stringType]),
+ intType
+ ])
+ ]),
+ env.types.asInstanceOf(F_int_string, A));
}
/**
@@ -97,16 +105,20 @@
* through [name1] is the same as the type found through [name2].
*/
void testSubstitution(
- compiler, arguments, parameters, String name1, String name2) {
- ResolutionDartType type1 = getType(compiler, name1);
- ResolutionDartType type2 = getType(compiler, name2);
- ResolutionDartType subst = type1.subst(arguments, parameters);
+ ElementEnvironment elementEnvironment,
+ List<DartType> arguments,
+ List<DartType> parameters,
+ String name1,
+ String name2) {
+ DartType type1 = getType(elementEnvironment, name1);
+ DartType type2 = getType(elementEnvironment, name2);
+ DartType subst = type1.subst(arguments, parameters);
Expect.equals(
type2, subst, "$type1.subst($arguments,$parameters)=$subst != $type2");
}
-void testTypeSubstitution() {
- asyncTest(() => TypeEnvironment.create(r"""
+testTypeSubstitution() async {
+ var env = await TypeEnvironment.create(r"""
typedef void Typedef1<X,Y>(X x1, Y y2);
typedef void Typedef2<Z>(Z z1);
@@ -158,99 +170,96 @@
void Typedef1e(Typedef2<S> a) {}
void Typedef2e(Typedef2<String> b) {}
}
- """, useOldFrontend: true).then((env) {
- var compiler = env.compiler;
+ """);
+ InterfaceType Class_T_S = env["Class"];
+ Expect.isNotNull(Class_T_S);
+ Expect.isTrue(Class_T_S.isInterfaceType);
+ Expect.equals(2, Class_T_S.typeArguments.length);
- ResolutionInterfaceType Class_T_S = env["Class"];
- Expect.isNotNull(Class_T_S);
- Expect.identical(Class_T_S.kind, ResolutionTypeKind.INTERFACE);
- Expect.equals(2, Class_T_S.typeArguments.length);
+ DartType T = Class_T_S.typeArguments[0];
+ Expect.isNotNull(T);
+ Expect.isTrue(T.isTypeVariable);
- ResolutionDartType T = Class_T_S.typeArguments[0];
- Expect.isNotNull(T);
- Expect.identical(T.kind, ResolutionTypeKind.TYPE_VARIABLE);
+ DartType S = Class_T_S.typeArguments[1];
+ Expect.isNotNull(S);
+ Expect.isTrue(S.isTypeVariable);
- ResolutionDartType S = Class_T_S.typeArguments[1];
- Expect.isNotNull(S);
- Expect.identical(S.kind, ResolutionTypeKind.TYPE_VARIABLE);
+ DartType intType = env['int']; //getType(compiler, "int1");
+ Expect.isNotNull(intType);
+ Expect.isTrue(intType.isInterfaceType);
- ResolutionDartType intType = env['int']; //getType(compiler, "int1");
- Expect.isNotNull(intType);
- Expect.identical(intType.kind, ResolutionTypeKind.INTERFACE);
+ DartType StringType = env['String']; //getType(compiler, "String1");
+ Expect.isNotNull(StringType);
+ Expect.isTrue(StringType.isInterfaceType);
- ResolutionDartType StringType =
- env['String']; //getType(compiler, "String1");
- Expect.isNotNull(StringType);
- Expect.identical(StringType.kind, ResolutionTypeKind.INTERFACE);
+ List<DartType> parameters = <DartType>[T, S];
+ List<DartType> arguments = <DartType>[intType, StringType];
- List<ResolutionDartType> parameters = <ResolutionDartType>[T, S];
- List<ResolutionDartType> arguments = <ResolutionDartType>[
- intType,
- StringType
- ];
+ // TODO(johnniwinther): Create types directly from strings to improve
+ // test readability.
- // TODO(johnniwinther): Create types directly from strings to improve
- // test readability.
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "void1", "void2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "dynamic1", "dynamic2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "int1", "int2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "String1", "String2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "ListInt1", "ListInt2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "ListT1", "ListT2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "ListS1", "ListS2");
+ testSubstitution(env.elementEnvironment, arguments, parameters, "ListListT1",
+ "ListListT2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "ListRaw1", "ListRaw2");
+ testSubstitution(env.elementEnvironment, arguments, parameters,
+ "ListDynamic1", "ListDynamic2");
+ testSubstitution(env.elementEnvironment, arguments, parameters,
+ "MapIntString1", "MapIntString2");
+ testSubstitution(env.elementEnvironment, arguments, parameters, "MapTString1",
+ "MapTString2");
+ testSubstitution(env.elementEnvironment, arguments, parameters,
+ "MapDynamicString1", "MapDynamicString2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "TypeVarT1", "TypeVarT2");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "TypeVarS1", "TypeVarS2");
+ testSubstitution(env.elementEnvironment, arguments, parameters, "Function1a",
+ "Function2a");
+ testSubstitution(env.elementEnvironment, arguments, parameters, "Function1b",
+ "Function2b");
+ testSubstitution(env.elementEnvironment, arguments, parameters, "Function1c",
+ "Function2c");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "Typedef1a", "Typedef2a");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "Typedef1b", "Typedef2b");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "Typedef1c", "Typedef2c");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "Typedef1d", "Typedef2d");
+ testSubstitution(
+ env.elementEnvironment, arguments, parameters, "Typedef1e", "Typedef2e");
- testSubstitution(compiler, arguments, parameters, "void1", "void2");
- testSubstitution(
- compiler, arguments, parameters, "dynamic1", "dynamic2");
- testSubstitution(compiler, arguments, parameters, "int1", "int2");
- testSubstitution(compiler, arguments, parameters, "String1", "String2");
- testSubstitution(
- compiler, arguments, parameters, "ListInt1", "ListInt2");
- testSubstitution(compiler, arguments, parameters, "ListT1", "ListT2");
- testSubstitution(compiler, arguments, parameters, "ListS1", "ListS2");
- testSubstitution(
- compiler, arguments, parameters, "ListListT1", "ListListT2");
- testSubstitution(
- compiler, arguments, parameters, "ListRaw1", "ListRaw2");
- testSubstitution(
- compiler, arguments, parameters, "ListDynamic1", "ListDynamic2");
- testSubstitution(
- compiler, arguments, parameters, "MapIntString1", "MapIntString2");
- testSubstitution(
- compiler, arguments, parameters, "MapTString1", "MapTString2");
- testSubstitution(compiler, arguments, parameters, "MapDynamicString1",
- "MapDynamicString2");
- testSubstitution(
- compiler, arguments, parameters, "TypeVarT1", "TypeVarT2");
- testSubstitution(
- compiler, arguments, parameters, "TypeVarS1", "TypeVarS2");
- testSubstitution(
- compiler, arguments, parameters, "Function1a", "Function2a");
- testSubstitution(
- compiler, arguments, parameters, "Function1b", "Function2b");
- testSubstitution(
- compiler, arguments, parameters, "Function1c", "Function2c");
- testSubstitution(
- compiler, arguments, parameters, "Typedef1a", "Typedef2a");
- testSubstitution(
- compiler, arguments, parameters, "Typedef1b", "Typedef2b");
- testSubstitution(
- compiler, arguments, parameters, "Typedef1c", "Typedef2c");
- testSubstitution(
- compiler, arguments, parameters, "Typedef1d", "Typedef2d");
- testSubstitution(
- compiler, arguments, parameters, "Typedef1e", "Typedef2e");
+ // Substitution in unalias.
+ DartType Typedef2_int_String = getType(env.elementEnvironment, "Typedef2a");
+ Expect.isNotNull(Typedef2_int_String);
+ DartType Function_int_String = getType(env.elementEnvironment, "Function2b");
+ Expect.isNotNull(Function_int_String);
+ DartType unalias1 = Typedef2_int_String.unaliased;
+ Expect.equals(Function_int_String, unalias1,
+ '$Typedef2_int_String.unalias=$unalias1 != $Function_int_String');
- // Substitution in unalias.
- ResolutionDartType Typedef2_int_String = getType(compiler, "Typedef2a");
- Expect.isNotNull(Typedef2_int_String);
- ResolutionDartType Function_int_String =
- getType(compiler, "Function2b");
- Expect.isNotNull(Function_int_String);
- ResolutionDartType unalias1 = Typedef2_int_String.unaliased;
- Expect.equals(Function_int_String, unalias1,
- '$Typedef2_int_String.unalias=$unalias1 != $Function_int_String');
-
- ResolutionDartType Typedef1 = getType(compiler, "Typedef1c");
- Expect.isNotNull(Typedef1);
- ResolutionDartType Function_dynamic_dynamic =
- getType(compiler, "Function1c");
- Expect.isNotNull(Function_dynamic_dynamic);
- ResolutionDartType unalias2 = Typedef1.unaliased;
- Expect.equals(Function_dynamic_dynamic, unalias2,
- '$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic');
- }));
+ DartType Typedef1 = getType(env.elementEnvironment, "Typedef1c");
+ Expect.isNotNull(Typedef1);
+ DartType Function_dynamic_dynamic =
+ getType(env.elementEnvironment, "Function1c");
+ Expect.isNotNull(Function_dynamic_dynamic);
+ DartType unalias2 = Typedef1.unaliased;
+ Expect.equals(Function_dynamic_dynamic, unalias2,
+ '$Typedef1.unalias=$unalias2 != $Function_dynamic_dynamic');
}
diff --git a/tests/compiler/dart2js/model/world_test.dart b/tests/compiler/dart2js/model/world_test.dart
index 7c1243c..135a7d2 100644
--- a/tests/compiler/dart2js/model/world_test.dart
+++ b/tests/compiler/dart2js/model/world_test.dart
@@ -15,10 +15,10 @@
void main() {
runTests({bool useOldFrontend}) async {
- await testClassSets(useOldFrontend: useOldFrontend);
- await testProperties(useOldFrontend: useOldFrontend);
- await testNativeClasses(useOldFrontend: useOldFrontend);
- await testCommonSubclasses(useOldFrontend: useOldFrontend);
+ await testClassSets();
+ await testProperties();
+ await testNativeClasses();
+ await testCommonSubclasses();
}
asyncTest(() async {
@@ -29,7 +29,7 @@
});
}
-testClassSets({bool useOldFrontend}) async {
+testClassSets() async {
var env = await TypeEnvironment.create(r"""
class A implements X {}
class B {}
@@ -53,7 +53,7 @@
html.window;
new html.Worker('');
}
- """, useOldFrontend: useOldFrontend);
+ """);
ClosedWorld closedWorld = env.closedWorld;
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
@@ -189,7 +189,7 @@
testMixinUses(X, []);
}
-testProperties({bool useOldFrontend}) async {
+testProperties() async {
var env = await TypeEnvironment.create(r"""
class A {}
class A1 extends A {}
@@ -244,7 +244,7 @@
new G3();
new H4();
}
- """, useOldFrontend: useOldFrontend);
+ """);
ClosedWorld closedWorld = env.closedWorld;
check(String name, {bool hasStrictSubtype, bool hasOnlySubclasses}) {
@@ -310,9 +310,8 @@
check("H4", hasStrictSubtype: false, hasOnlySubclasses: true);
}
-testNativeClasses({bool useOldFrontend}) async {
- var env = await TypeEnvironment.create('',
- mainSource: r"""
+testNativeClasses() async {
+ var env = await TypeEnvironment.create('', mainSource: r"""
import 'dart:html' as html;
main() {
html.window; // Creates 'Window'.
@@ -320,8 +319,7 @@
new html.CanvasElement() // Creates CanvasElement
..getContext(''); // Creates CanvasRenderingContext2D
}
- """,
- useOldFrontend: useOldFrontend);
+ """);
ClosedWorld closedWorld = env.closedWorld;
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
LibraryEntity dart_html = elementEnvironment.lookupLibrary(Uris.dart_html);
@@ -520,9 +518,8 @@
instantiatedSubtypeCount: 0);
}
-testCommonSubclasses({bool useOldFrontend}) async {
- var env = await TypeEnvironment.create('',
- mainSource: r"""
+testCommonSubclasses() async {
+ var env = await TypeEnvironment.create('', mainSource: r"""
class A {}
class B {}
class C extends A {}
@@ -545,8 +542,7 @@
new I();
new J();
}
- """,
- useOldFrontend: useOldFrontend);
+ """);
ClosedWorld closedWorld = env.closedWorld;
ClassEntity A = env.getElement("A");
diff --git a/tests/compiler/dart2js/needs_no_such_method_test.dart b/tests/compiler/dart2js/needs_no_such_method_test.dart
index b02fceb..e216047 100644
--- a/tests/compiler/dart2js/needs_no_such_method_test.dart
+++ b/tests/compiler/dart2js/needs_no_such_method_test.dart
@@ -14,10 +14,8 @@
void main() {
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await testClassSets(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await testClassSets(useOldFrontend: false);
+ await testClassSets();
});
}
@@ -33,7 +31,7 @@
}
""";
-testClassSets({bool useOldFrontend}) async {
+testClassSets() async {
Selector foo, bar, baz;
ClosedWorld closedWorld;
ClassEntity superclass, subclass, subtype;
@@ -48,8 +46,8 @@
main.write('}');
testMode = '$instantiated';
- var env = await TypeEnvironment.create(CLASSES,
- mainSource: main.toString(), useOldFrontend: useOldFrontend);
+ var env =
+ await TypeEnvironment.create(CLASSES, mainSource: main.toString());
foo = new Selector.call(const PublicName('foo'), CallStructure.NO_ARGS);
bar = new Selector.call(const PublicName('bar'), CallStructure.NO_ARGS);
baz = new Selector.call(const PublicName('baz'), CallStructure.NO_ARGS);
diff --git a/tests/compiler/dart2js/receiver_type_test.dart b/tests/compiler/dart2js/receiver_type_test.dart
index 64b2c8e..da0a7a2 100644
--- a/tests/compiler/dart2js/receiver_type_test.dart
+++ b/tests/compiler/dart2js/receiver_type_test.dart
@@ -13,14 +13,12 @@
main() {
asyncTest(() async {
- print('--test from ast---------------------------------------------------');
- await runTest(useOldFrontend: true);
print('--test from kernel------------------------------------------------');
- await runTest(useOldFrontend: false);
+ await runTest();
});
}
-Future runTest({bool useOldFrontend}) async {
+Future runTest() async {
var env = await TypeEnvironment.create("""
class A {
call() {}
@@ -38,7 +36,7 @@
localFunction() {}
() {};
}
- """, useOldFrontend: useOldFrontend, testBackendWorld: true);
+ """, testBackendWorld: true);
Map<String, String> expectedMap = const {
'A': '[exact=A]',
diff --git a/tests/compiler/dart2js/type_test_helper.dart b/tests/compiler/dart2js/type_test_helper.dart
index cd84761..9705244 100644
--- a/tests/compiler/dart2js/type_test_helper.dart
+++ b/tests/compiler/dart2js/type_test_helper.dart
@@ -45,8 +45,7 @@
String mainSource,
bool testBackendWorld: false,
List<String> options: const <String>[],
- Map<String, String> fieldTypeMap: const <String, String>{},
- bool useOldFrontend: false}) async {
+ Map<String, String> fieldTypeMap: const <String, String>{}}) async {
Uri uri;
Compiler compiler;
if (mainSource != null) {
@@ -64,39 +63,19 @@
source = '$mainSource\n$source';
}
memory.DiagnosticCollector collector;
- if (!useOldFrontend) {
- collector = new memory.DiagnosticCollector();
- uri = Uri.parse('memory:main.dart');
- compiler = await dill.compileWithDill(
- entryPoint: uri,
- memorySourceFiles: {'main.dart': source},
- diagnosticHandler: collector,
- options: stopAfterTypeInference
- ? ([Flags.disableTypeInference]..addAll(options))
- : ([
- Flags.disableTypeInference,
- Flags.analyzeAll,
- Flags.analyzeOnly
- ]..addAll(options)),
- beforeRun: (Compiler compiler) {
- compiler.stopAfterTypeInference = stopAfterTypeInference;
- });
- } else {
- collector = new memory.DiagnosticCollector();
- uri = Uri.parse('memory:main.dart');
- memory.CompilationResult result = await memory.runCompiler(
- entryPoint: uri,
- memorySourceFiles: {'main.dart': source},
- diagnosticHandler: collector,
- options: stopAfterTypeInference
- ? ([Flags.useOldFrontend]..addAll(options))
- : ([Flags.useOldFrontend, Flags.analyzeAll, Flags.analyzeOnly]
- ..addAll(options)),
- beforeRun: (compiler) {
- compiler.stopAfterTypeInference = stopAfterTypeInference;
- });
- compiler = result.compiler;
- }
+ collector = new memory.DiagnosticCollector();
+ uri = Uri.parse('memory:main.dart');
+ compiler = await dill.compileWithDill(
+ entryPoint: uri,
+ memorySourceFiles: {'main.dart': source},
+ diagnosticHandler: collector,
+ options: stopAfterTypeInference
+ ? ([Flags.disableTypeInference]..addAll(options))
+ : ([Flags.disableTypeInference, Flags.analyzeAll, Flags.analyzeOnly]
+ ..addAll(options)),
+ beforeRun: (Compiler compiler) {
+ compiler.stopAfterTypeInference = stopAfterTypeInference;
+ });
if (expectNoErrors || expectNoWarningsOrErrors) {
var errors = collector.errors;
Expect.isTrue(errors.isEmpty, 'Unexpected errors: ${errors}');