Index: tests/compiler/dart2js/field_type_simple_inferer_test.dart |
diff --git a/tests/compiler/dart2js/field_type_simple_inferer_test.dart b/tests/compiler/dart2js/field_type_simple_inferer_test.dart |
index 03d7de377128e3796ea2421b411f8d2a9bd82368..0e930a09c65b8a57ec4ff8601677c83aea9ddef2 100644 |
--- a/tests/compiler/dart2js/field_type_simple_inferer_test.dart |
+++ b/tests/compiler/dart2js/field_type_simple_inferer_test.dart |
@@ -5,6 +5,8 @@ |
import 'package:expect/expect.dart'; |
import 'package:async_helper/async_helper.dart'; |
import 'package:compiler/src/types/types.dart' show TypeMask; |
+import 'package:compiler/src/types/masks.dart' show CommonMasks; |
+import 'package:compiler/src/compiler.dart' show Compiler; |
import 'compiler_helper.dart'; |
import 'type_mask_test_helper.dart'; |
@@ -469,11 +471,14 @@ const String TEST_27 = r""" |
} |
"""; |
-void doTest(String test, bool disableInlining, Map<String, Function> fields) { |
- fields.forEach((String name, Function f) { |
+typedef TypeMask TestCallback(Compiler compiler, CommonMasks masks); |
+ |
+void doTest( |
+ String test, bool disableInlining, Map<String, TestCallback> fields) { |
+ fields.forEach((String name, TestCallback f) { |
compileAndFind(test, 'A', name, disableInlining, (compiler, field) { |
- TypeMask type = f(compiler.commonMasks); |
- var inferrer = compiler.globalInference.typesInferrer; |
+ TypeMask type = f(compiler, compiler.closedWorld.commonMasks); |
+ var inferrer = compiler.globalInference.typesInferrerInternal; |
TypeMask inferredType = |
simplify(inferrer.getTypeOfElement(field), inferrer.compiler); |
Expect.equals(type, inferredType, test); |
@@ -481,92 +486,120 @@ void doTest(String test, bool disableInlining, Map<String, Function> fields) { |
}); |
} |
-void runTest(String test, Map<String, Function> fields) { |
+void runTest(String test, Map<String, TestCallback> fields) { |
doTest(test, false, fields); |
doTest(test, true, fields); |
} |
void test() { |
- subclassOfInterceptor(types) => |
- findTypeMask(types.compiler, 'Interceptor', 'nonNullSubclass'); |
- |
- runTest(TEST_1, {'f': (types) => types.nullType}); |
- runTest(TEST_2, |
- {'f1': (types) => types.nullType, 'f2': (types) => types.uint31Type}); |
- runTest(TEST_3, { |
- 'f1': (types) => types.uint31Type, |
- 'f2': (types) => types.uint31Type.nullable() |
+ TypeMask subclassOfInterceptor(Compiler compiler, CommonMasks types) => |
+ findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
+ |
+ runTest( |
+ TEST_1, <String, TestCallback>{'f': (compiler, types) => types.nullType}); |
+ runTest(TEST_2, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.nullType, |
+ 'f2': (compiler, types) => types.uint31Type |
+ }); |
+ runTest(TEST_3, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.uint31Type, |
+ 'f2': (compiler, types) => types.uint31Type.nullable() |
}); |
- runTest(TEST_4, { |
+ runTest(TEST_4, <String, TestCallback>{ |
'f1': subclassOfInterceptor, |
- 'f2': (types) => types.stringType.nullable() |
+ 'f2': (compiler, types) => types.stringType.nullable() |
}); |
// TODO(ngeoffray): We should try to infer that the initialization |
// code at the declaration site of the fields does not matter. |
- runTest(TEST_5, {'f1': subclassOfInterceptor, 'f2': subclassOfInterceptor}); |
- runTest(TEST_6, {'f1': subclassOfInterceptor, 'f2': subclassOfInterceptor}); |
- runTest(TEST_7, {'f1': subclassOfInterceptor, 'f2': subclassOfInterceptor}); |
+ runTest(TEST_5, <String, TestCallback>{ |
+ 'f1': subclassOfInterceptor, |
+ 'f2': subclassOfInterceptor |
+ }); |
+ runTest(TEST_6, <String, TestCallback>{ |
+ 'f1': subclassOfInterceptor, |
+ 'f2': subclassOfInterceptor |
+ }); |
+ runTest(TEST_7, <String, TestCallback>{ |
+ 'f1': subclassOfInterceptor, |
+ 'f2': subclassOfInterceptor |
+ }); |
- runTest(TEST_8, {'f': (types) => types.stringType.nullable()}); |
- runTest(TEST_9, {'f': (types) => types.stringType.nullable()}); |
- runTest(TEST_10, {'f': (types) => types.uint31Type}); |
- runTest(TEST_11, {'fs': (types) => types.uint31Type}); |
+ runTest(TEST_8, <String, TestCallback>{ |
+ 'f': (compiler, types) => types.stringType.nullable() |
+ }); |
+ runTest(TEST_9, <String, TestCallback>{ |
+ 'f': (compiler, types) => types.stringType.nullable() |
+ }); |
+ runTest(TEST_10, |
+ <String, TestCallback>{'f': (compiler, types) => types.uint31Type}); |
+ runTest(TEST_11, |
+ <String, TestCallback>{'fs': (compiler, types) => types.uint31Type}); |
// TODO(ngeoffray): We should try to infer that the initialization |
// code at the declaration site of the fields does not matter. |
- runTest(TEST_12, {'fs': subclassOfInterceptor}); |
- |
- runTest(TEST_13, {'fs': (types) => types.uint31Type}); |
- runTest(TEST_14, {'f': (types) => types.uint31Type}); |
- runTest(TEST_15, { |
- 'f': (types) { |
- ClassElement cls = types.compiler.backend.helpers.jsIndexableClass; |
- return new TypeMask.nonNullSubtype(cls, types.compiler.closedWorld); |
+ runTest(TEST_12, <String, TestCallback>{'fs': subclassOfInterceptor}); |
+ |
+ runTest(TEST_13, |
+ <String, TestCallback>{'fs': (compiler, types) => types.uint31Type}); |
+ runTest(TEST_14, |
+ <String, TestCallback>{'f': (compiler, types) => types.uint31Type}); |
+ runTest(TEST_15, <String, TestCallback>{ |
+ 'f': (compiler, types) { |
+ ClassElement cls = compiler.backend.helpers.jsIndexableClass; |
+ return new TypeMask.nonNullSubtype(cls, compiler.closedWorld); |
} |
}); |
- runTest(TEST_16, {'f': subclassOfInterceptor}); |
- runTest(TEST_17, {'f': (types) => types.uint31Type.nullable()}); |
- runTest(TEST_18, { |
- 'f1': (types) => types.uint31Type, |
- 'f2': (types) => types.stringType, |
- 'f3': (types) => types.dynamicType |
+ runTest(TEST_16, <String, TestCallback>{'f': subclassOfInterceptor}); |
+ runTest(TEST_17, <String, TestCallback>{ |
+ 'f': (compiler, types) => types.uint31Type.nullable() |
+ }); |
+ runTest(TEST_18, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.uint31Type, |
+ 'f2': (compiler, types) => types.stringType, |
+ 'f3': (compiler, types) => types.dynamicType |
+ }); |
+ runTest(TEST_19, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.uint31Type, |
+ 'f2': (compiler, types) => types.stringType, |
+ 'f3': (compiler, types) => types.dynamicType |
+ }); |
+ runTest(TEST_20, <String, TestCallback>{ |
+ 'f': (compiler, types) => types.uint31Type.nullable() |
}); |
- runTest(TEST_19, { |
- 'f1': (types) => types.uint31Type, |
- 'f2': (types) => types.stringType, |
- 'f3': (types) => types.dynamicType |
+ runTest(TEST_21, <String, TestCallback>{ |
+ 'f': (compiler, types) => types.uint31Type.nullable() |
}); |
- runTest(TEST_20, {'f': (types) => types.uint31Type.nullable()}); |
- runTest(TEST_21, {'f': (types) => types.uint31Type.nullable()}); |
- runTest(TEST_22, { |
- 'f1': (types) => types.uint31Type, |
- 'f2': (types) => types.uint31Type, |
- 'f3': (types) => types.stringType.nullable() |
+ runTest(TEST_22, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.uint31Type, |
+ 'f2': (compiler, types) => types.uint31Type, |
+ 'f3': (compiler, types) => types.stringType.nullable() |
}); |
- runTest(TEST_23, { |
- 'f1': (types) => types.uint31Type.nullable(), |
- 'f2': (types) => types.uint31Type.nullable(), |
- 'f3': (types) => types.uint31Type.nullable(), |
- 'f4': (types) => types.uint31Type.nullable() |
+ runTest(TEST_23, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.uint31Type.nullable(), |
+ 'f2': (compiler, types) => types.uint31Type.nullable(), |
+ 'f3': (compiler, types) => types.uint31Type.nullable(), |
+ 'f4': (compiler, types) => types.uint31Type.nullable() |
}); |
- runTest(TEST_24, { |
- 'f1': (types) => types.positiveIntType, |
- 'f2': (types) => types.positiveIntType, |
- 'f3': (types) => types.uint31Type, |
- 'f4': (types) => types.uint31Type, |
- 'f5': (types) => types.numType.nullable(), |
- 'f6': (types) => types.stringType.nullable() |
+ runTest(TEST_24, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.positiveIntType, |
+ 'f2': (compiler, types) => types.positiveIntType, |
+ 'f3': (compiler, types) => types.uint31Type, |
+ 'f4': (compiler, types) => types.uint31Type, |
+ 'f5': (compiler, types) => types.numType.nullable(), |
+ 'f6': (compiler, types) => types.stringType.nullable() |
}); |
- runTest(TEST_25, {'f1': (types) => types.uint31Type}); |
- runTest(TEST_26, {'f1': (types) => types.positiveIntType}); |
- runTest(TEST_27, { |
- 'f1': (types) => types.uint31Type, |
- 'f2': (types) => types.uint31Type.nullable() |
+ runTest(TEST_25, |
+ <String, TestCallback>{'f1': (compiler, types) => types.uint31Type}); |
+ runTest(TEST_26, |
+ <String, TestCallback>{'f1': (compiler, types) => types.positiveIntType}); |
+ runTest(TEST_27, <String, TestCallback>{ |
+ 'f1': (compiler, types) => types.uint31Type, |
+ 'f2': (compiler, types) => types.uint31Type.nullable() |
}); |
} |