@@ -581,11 +581,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
581
581
582
582
var finishGenericTypeTest = _emitClassTypeTests (c, className, body);
583
583
584
- // Attach caches on all canonicalized types not in our runtime.
585
- // Types in the runtime will have caches attached in their constructors.
586
- if (! isSdkInternalRuntime (_currentLibrary)) {
587
- body.add (runtimeStatement ('addTypeCaches(#)' , [className]));
588
- }
584
+ // Attach caches on all canonicalized types.
585
+ body.add (runtimeStatement ('addTypeCaches(#)' , [className]));
589
586
590
587
_emitVirtualFieldSymbols (c, body);
591
588
_emitClassSignature (c, className, body);
@@ -1082,29 +1079,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
1082
1079
}
1083
1080
1084
1081
if (c == _coreTypes.deprecatedFutureOrClass) {
1085
- // These methods are difficult to place in the runtime or patch files.
1086
- // * They need to be callable from the class but they can't be static
1087
- // methods on the FutureOr class in Dart because they reference the
1088
- // generic type parameter.
1089
- // * There isn't an obvious place in dart:_runtime were we could place a
1090
- // method that adds these type tests (similar to addTypeTests()) because
1091
- // in the bootstrap ordering the Future class hasn't been defined yet.
1092
- var typeParam =
1093
- TypeParameterType (c.typeParameters[0 ], Nullability .undetermined);
1094
- var typeT = visitTypeParameterType (typeParam);
1095
- var futureOfT = visitInterfaceType (InterfaceType (
1096
- _coreTypes.futureClass, currentLibrary.nonNullable, [typeParam]));
1097
- body.add (js.statement ('''
1098
- #.is = function is_FutureOr(o) {
1099
- return #.is(o) || #.is(o);
1100
- }
1101
- ''' , [className, typeT, futureOfT]));
1102
- body.add (js.statement ('''
1103
- #.as = function as_FutureOr(o) {
1104
- if (#.is(o) || #.is(o)) return o;
1105
- return #.as(o, this);
1106
- }
1107
- ''' , [className, typeT, futureOfT, runtimeModule]));
1082
+ // Custom type tests for FutureOr types are attached when the type is
1083
+ // constructed in the runtime normalizeFutureOr method.
1108
1084
return null ;
1109
1085
}
1110
1086
0 commit comments