@@ -273,6 +273,9 @@ final _cachedNullable = JS('', 'Symbol("cachedNullable")');
273
273
/// A javascript Symbol used to store a canonical version of T* on T.
274
274
final _cachedLegacy = JS ('' , 'Symbol("cachedLegacy")' );
275
275
276
+ /// A javascript Symbol used to store prior subtype checks and their results.
277
+ final _subtypeCache = JS ('' , 'Symbol("_subtypeCache")' );
278
+
276
279
/// Returns a nullable (question, ?) version of [type] .
277
280
///
278
281
/// The resulting type returned in a normalized form based on the rules from the
@@ -1235,17 +1238,9 @@ _isFunctionSubtype(ft1, ft2, bool strictMode) => JS('', '''(() => {
1235
1238
bool isSubtypeOf (Object t1, Object t2) {
1236
1239
// TODO(jmesserly): we've optimized `is`/`as`/implicit type checks, so they're
1237
1240
// dispatched on the type. Can we optimize the subtype relation too?
1238
- // TODO: Find a way to eagerly attach this cache to the Null object at
1239
- // compile-time so we can remove the top-level null comparison cache entirely.
1240
- Object map;
1241
- if (JS ('!' , '!#.hasOwnProperty(#)' , t1, _subtypeCache)) {
1242
- JS ('' , '#[#] = #' , t1, _subtypeCache, map = JS <Object >('!' , 'new Map()' ));
1243
- _cacheMaps.add (map);
1244
- } else {
1245
- map = JS <Object >('!' , '#[#]' , t1, _subtypeCache);
1246
- bool result = JS ('' , '#.get(#)' , map, t2);
1247
- if (JS ('!' , '# !== void 0' , result)) return result;
1248
- }
1241
+ var map = JS <Object >('!' , '#[#]' , t1, _subtypeCache);
1242
+ bool result = JS ('' , '#.get(#)' , map, t2);
1243
+ if (JS ('!' , '# !== void 0' , result)) return result;
1249
1244
1250
1245
var validSubtype = _isSubtype (t1, t2, true );
1251
1246
if (! validSubtype && ! _strictSubtypeChecks) {
@@ -1261,8 +1256,6 @@ bool isSubtypeOf(Object t1, Object t2) {
1261
1256
return validSubtype;
1262
1257
}
1263
1258
1264
- final _subtypeCache = JS ('' , 'Symbol("_subtypeCache")' );
1265
-
1266
1259
@notNull
1267
1260
bool _isBottom (type, @notNull bool strictMode) =>
1268
1261
_equalType (type, Never ) || (! strictMode && _equalType (type, Null ));
0 commit comments