@@ -273,6 +273,9 @@ final _cachedNullable = JS('', 'Symbol("cachedNullable")');
273273/// A javascript Symbol used to store a canonical version of T* on T.
274274final _cachedLegacy = JS ('' , 'Symbol("cachedLegacy")' );
275275
276+ /// A javascript Symbol used to store prior subtype checks and their results.
277+ final _subtypeCache = JS ('' , 'Symbol("_subtypeCache")' );
278+
276279/// Returns a nullable (question, ?) version of [type] .
277280///
278281/// The resulting type returned in a normalized form based on the rules from the
@@ -1235,17 +1238,9 @@ _isFunctionSubtype(ft1, ft2, bool strictMode) => JS('', '''(() => {
12351238bool isSubtypeOf (Object t1, Object t2) {
12361239 // TODO(jmesserly): we've optimized `is`/`as`/implicit type checks, so they're
12371240 // 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;
12491244
12501245 var validSubtype = _isSubtype (t1, t2, true );
12511246 if (! validSubtype && ! _strictSubtypeChecks) {
@@ -1261,8 +1256,6 @@ bool isSubtypeOf(Object t1, Object t2) {
12611256 return validSubtype;
12621257}
12631258
1264- final _subtypeCache = JS ('' , 'Symbol("_subtypeCache")' );
1265-
12661259@notNull
12671260bool _isBottom (type, @notNull bool strictMode) =>
12681261 _equalType (type, Never ) || (! strictMode && _equalType (type, Null ));
0 commit comments