@@ -84,12 +84,12 @@ class Rti {
8484 rti._is = fn;
8585 }
8686
87- @pragma ('dart2js:tryInline ' )
87+ @pragma ('dart2js:prefer-inline ' )
8888 static Object ? _asCheck (Rti rti, Object ? object) {
8989 return JS ('' , '#.#(#)' , rti, JS_GET_NAME (JsGetName .RTI_FIELD_AS ), object);
9090 }
9191
92- @pragma ('dart2js:tryInline ' )
92+ @pragma ('dart2js:prefer-inline ' )
9393 static bool _isCheck (Rti rti, Object ? object) {
9494 return JS (
9595 'bool' ,
@@ -1215,36 +1215,35 @@ bool _installSpecializedIsTest(Object? object) {
12151215 // This static method is installed on an Rti object as a JavaScript instance
12161216 // method. The Rti object is 'this'.
12171217 Rti testRti = _Utils .asRti (JS ('' , 'this' ));
1218+ final isFn = _specializedIsTest (testRti);
1219+ Rti ._setIsTestFunction (testRti, isFn);
1220+ return Rti ._isCheck (testRti, object);
1221+ }
12181222
1219- if (isObjectType (testRti)) {
1220- return _finishIsFn (testRti, object, RAW_DART_FUNCTION_REF (_isObject));
1221- }
1222- if (isTopType (testRti)) {
1223- return _finishIsFn (testRti, object, RAW_DART_FUNCTION_REF (_isTop));
1224- }
1223+ /// Returns a raw function reference for a specialized `_is` test. Also installs
1224+ /// 'resources' on [testRti] if the specialized function needs additional data
1225+ /// to perform the test.
1226+ Object ? _specializedIsTest (Rti testRti) {
1227+ if (isObjectType (testRti)) return RAW_DART_FUNCTION_REF (_isObject);
1228+
1229+ if (isTopType (testRti)) return RAW_DART_FUNCTION_REF (_isTop);
12251230
12261231 int kind = Rti ._getKind (testRti);
12271232
12281233 if (kind == Rti .kindQuestion) {
1229- return _finishIsFn (
1230- testRti,
1231- object,
1232- RAW_DART_FUNCTION_REF (_generalNullableIsTestImplementation),
1233- );
1234+ return RAW_DART_FUNCTION_REF (_generalNullableIsTestImplementation);
12341235 }
12351236
12361237 if (kind == Rti .kindNever) {
1237- return _finishIsFn (testRti, object, RAW_DART_FUNCTION_REF (_isNever) );
1238+ return RAW_DART_FUNCTION_REF (_isNever);
12381239 }
12391240
12401241 if (kind == Rti .kindFutureOr) {
1241- return _finishIsFn (testRti, object, RAW_DART_FUNCTION_REF (_isFutureOr) );
1242+ return RAW_DART_FUNCTION_REF (_isFutureOr);
12421243 }
12431244
1244- var isFn = _simpleSpecializedIsTest (testRti);
1245- if (isFn != null ) {
1246- return _finishIsFn (testRti, object, isFn);
1247- }
1245+ final simpleIsFn = _simpleSpecializedIsTest (testRti);
1246+ if (simpleIsFn != null ) return simpleIsFn;
12481247
12491248 if (kind == Rti .kindInterface) {
12501249 String name = Rti ._getInterfaceName (testRti);
@@ -1261,56 +1260,43 @@ bool _installSpecializedIsTest(Object? object) {
12611260 : '${JS_GET_NAME (JsGetName .OPERATOR_IS_PREFIX )}${name }' ;
12621261 Rti ._setSpecializedTestResource (testRti, propertyName);
12631262 if (name == JS_GET_NAME (JsGetName .LIST_CLASS_TYPE_NAME )) {
1264- return _finishIsFn (
1265- testRti,
1266- object,
1267- RAW_DART_FUNCTION_REF (_isListTestViaProperty),
1268- );
1263+ return RAW_DART_FUNCTION_REF (_isListTestViaProperty);
12691264 }
12701265 if (_Utils .isIdentical (testRti, TYPE_REF <JSObject >())) {
1271- return _finishIsFn (testRti, object, RAW_DART_FUNCTION_REF (_isJSObject) );
1266+ return RAW_DART_FUNCTION_REF (_isJSObject);
12721267 }
1273- return _finishIsFn (
1274- testRti,
1275- object,
1276- RAW_DART_FUNCTION_REF (_isTestViaProperty),
1277- );
1268+ return RAW_DART_FUNCTION_REF (_isTestViaProperty);
12781269 }
1270+
12791271 // fall through to general implementation.
12801272 } else if (kind == Rti .kindRecord) {
1281- isFn = _recordSpecializedIsTest (testRti);
1282- return _finishIsFn (testRti, object, isFn);
1273+ return _recordSpecializedIsTest (testRti);
12831274 }
1284- return _finishIsFn (
1285- testRti,
1286- object,
1287- RAW_DART_FUNCTION_REF (_generalIsTestImplementation),
1288- );
1289- }
1290-
1291- @pragma ('dart2js:noInline' ) // Slightly smaller code.
1292- bool _finishIsFn (Rti testRti, Object ? object, Object ? isFn) {
1293- Rti ._setIsTestFunction (testRti, isFn);
1294- return Rti ._isCheck (testRti, object);
1275+ return RAW_DART_FUNCTION_REF (_generalIsTestImplementation);
12951276}
12961277
12971278Object ? _simpleSpecializedIsTest (Rti testRti) {
12981279 // Note: We must not match `Never` below.
1299- var isFn = null ;
1300- if (_Utils .isIdentical (testRti, TYPE_REF <int >())) {
1301- isFn = RAW_DART_FUNCTION_REF (_isInt);
1302- } else if (_Utils .isIdentical (testRti, TYPE_REF <double >()) ||
1303- _Utils .isIdentical (testRti, TYPE_REF <num >())) {
1304- isFn = RAW_DART_FUNCTION_REF (_isNum);
1305- } else if (_Utils .isIdentical (testRti, TYPE_REF <String >())) {
1306- isFn = RAW_DART_FUNCTION_REF (_isString);
1307- } else if (_Utils .isIdentical (testRti, TYPE_REF <bool >())) {
1308- isFn = RAW_DART_FUNCTION_REF (_isBool);
1280+ int kind = Rti ._getKind (testRti);
1281+ if (kind == Rti .kindInterface) {
1282+ if (_Utils .isIdentical (testRti, TYPE_REF <int >())) {
1283+ return RAW_DART_FUNCTION_REF (_isInt);
1284+ }
1285+ if (_Utils .isIdentical (testRti, TYPE_REF <double >()) ||
1286+ _Utils .isIdentical (testRti, TYPE_REF <num >())) {
1287+ return RAW_DART_FUNCTION_REF (_isNum);
1288+ }
1289+ if (_Utils .isIdentical (testRti, TYPE_REF <String >())) {
1290+ return RAW_DART_FUNCTION_REF (_isString);
1291+ }
1292+ if (_Utils .isIdentical (testRti, TYPE_REF <bool >())) {
1293+ return RAW_DART_FUNCTION_REF (_isBool);
1294+ }
13091295 }
1310- return isFn ;
1296+ return null ;
13111297}
13121298
1313- Object ? _recordSpecializedIsTest (Rti testRti) {
1299+ Object _recordSpecializedIsTest (Rti testRti) {
13141300 final partialShapeTag = Rti ._getRecordPartialShapeTag (testRti);
13151301 final fieldRtis = Rti ._getRecordFields (testRti);
13161302 final predicate = records.createRecordTypePredicate (
@@ -1328,39 +1314,44 @@ Object? _installSpecializedAsCheck(Object? object) {
13281314 // This static method is installed on an Rti object as a JavaScript instance
13291315 // method. The Rti object is 'this'.
13301316 Rti testRti = _Utils .asRti (JS ('' , 'this' ));
1317+ final asFn = _specializedAsCheck (testRti);
1318+ Rti ._setAsCheckFunction (testRti, asFn);
1319+ return Rti ._asCheck (testRti, object);
1320+ }
13311321
1322+ Object ? _specializedAsCheck (Rti testRti) {
13321323 var asFn = RAW_DART_FUNCTION_REF (_generalAsCheckImplementation);
13331324 if (isTopType (testRti)) {
13341325 asFn = RAW_DART_FUNCTION_REF (_asTop);
13351326 } else if (isObjectType (testRti)) {
13361327 asFn = RAW_DART_FUNCTION_REF (_asObject);
13371328 } else if (isNullable (testRti)) {
13381329 asFn = RAW_DART_FUNCTION_REF (_generalNullableAsCheckImplementation);
1339- }
1340- if ( _Utils . isIdentical (testRti, TYPE_REF < int >())) {
1341- asFn = RAW_DART_FUNCTION_REF (_asInt);
1342- } else if ( _Utils . isIdentical (testRti, TYPE_REF < int ?>())) {
1343- asFn = RAW_DART_FUNCTION_REF (_asIntQ);
1344- } else if ( _Utils . isIdentical (testRti, TYPE_REF < String >())) {
1345- asFn = RAW_DART_FUNCTION_REF (_asString);
1346- } else if ( _Utils . isIdentical (testRti, TYPE_REF < String ?>())) {
1347- asFn = RAW_DART_FUNCTION_REF (_asStringQ);
1348- } else if ( _Utils . isIdentical (testRti, TYPE_REF < bool >())) {
1349- asFn = RAW_DART_FUNCTION_REF (_asBool);
1350- } else if ( _Utils . isIdentical (testRti, TYPE_REF < bool ?>())) {
1351- asFn = RAW_DART_FUNCTION_REF (_asBoolQ);
1352- } else if ( _Utils . isIdentical (testRti, TYPE_REF < num >())) {
1353- asFn = RAW_DART_FUNCTION_REF (_asNum);
1354- } else if ( _Utils . isIdentical (testRti, TYPE_REF < num ?>())) {
1355- asFn = RAW_DART_FUNCTION_REF (_asNumQ);
1356- } else if ( _Utils . isIdentical (testRti, TYPE_REF < double >())) {
1357- asFn = RAW_DART_FUNCTION_REF (_asDouble);
1358- } else if ( _Utils . isIdentical (testRti, TYPE_REF < double ?>())) {
1359- asFn = RAW_DART_FUNCTION_REF (_asDoubleQ);
1360- }
1361-
1362- Rti . _setAsCheckFunction (testRti, asFn);
1363- return Rti . _asCheck (testRti, object) ;
1330+ if ( _Utils . isIdentical (testRti, TYPE_REF < int ?>())) {
1331+ asFn = RAW_DART_FUNCTION_REF (_asIntQ);
1332+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < String ?>())) {
1333+ asFn = RAW_DART_FUNCTION_REF (_asStringQ);
1334+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < bool ?>())) {
1335+ asFn = RAW_DART_FUNCTION_REF (_asBoolQ);
1336+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < num ?>())) {
1337+ asFn = RAW_DART_FUNCTION_REF (_asNumQ);
1338+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < double ?>())) {
1339+ asFn = RAW_DART_FUNCTION_REF (_asDoubleQ);
1340+ }
1341+ } else {
1342+ if ( _Utils . isIdentical (testRti, TYPE_REF < int >())) {
1343+ asFn = RAW_DART_FUNCTION_REF (_asInt);
1344+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < String >())) {
1345+ asFn = RAW_DART_FUNCTION_REF (_asString);
1346+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < bool >())) {
1347+ asFn = RAW_DART_FUNCTION_REF (_asBool);
1348+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < num >())) {
1349+ asFn = RAW_DART_FUNCTION_REF (_asNum);
1350+ } else if ( _Utils . isIdentical (testRti, TYPE_REF < double >())) {
1351+ asFn = RAW_DART_FUNCTION_REF (_asDouble);
1352+ }
1353+ }
1354+ return asFn ;
13641355}
13651356
13661357/// Called from generated code.
0 commit comments