Skip to content

Commit a6b0cd8

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] new-rti: tweak instanceType for closures
Change-Id: I5d8a0aabde06e457211d674f7c990ce6d5c43214 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112500 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
1 parent 62325f9 commit a6b0cd8

File tree

1 file changed

+7
-5
lines changed
  • sdk/lib/_internal/js_runtime/lib

1 file changed

+7
-5
lines changed

sdk/lib/_internal/js_runtime/lib/rti.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,16 @@ Rti instanceType(object) {
375375
var rti = JS('', r'#[#]', object, JS_GET_NAME(JsGetName.RTI_NAME));
376376
if (rti != null) return _castToRti(rti);
377377

378-
// Subclasses of Closure are synthetic classes, so make them appear to be
379-
// the 'Closure' class.
378+
// Subclasses of Closure are synthetic classes. The synthetic classes all
379+
// extend a 'normal' class (Closure, BoundClosure, StaticClosure), so make
380+
// them appear to be the superclass.
380381
// TODO(sra): Can this be done less expensively, e.g. by putting $ti on the
381-
// prototype of Closure class?
382+
// prototype of Closure/BoundClosure/StaticClosure classes?
382383
var closureClassConstructor = JS_BUILTIN(
383384
'depends:none;effects:none;', JsBuiltin.dartClosureConstructor);
384385
if (_Utils.instanceOf(object, closureClassConstructor)) {
385-
return _instanceTypeFromConstructor(closureClassConstructor);
386+
return _instanceTypeFromConstructor(
387+
JS('', '#.__proto__.__proto__.constructor', object));
386388
}
387389

388390
return _instanceTypeFromConstructor(JS('', '#.constructor', object));
@@ -441,7 +443,7 @@ Rti getTypeFromTypesTable(/*int*/ _index) {
441443
}
442444

443445
Type getRuntimeType(object) {
444-
Rti rti = instanceType(object);
446+
Rti rti = _instanceFunctionType(object) ?? instanceType(object);
445447
return _createRuntimeType(rti);
446448
}
447449

0 commit comments

Comments
 (0)