dart2js: Make BoundClosures work with dummy receiver optimization #15933
Labels
area-web
Issues related to Dart Web.
P3
A lower priority bug or feature request
type-enhancement
A request for a change that isn't a bug
web-dart2js
BoundClosure type tests fail with the dummy-receiver optimization because the type test looks into the closure to find the receiver, but finds the dummy receiver instead of the true receiver.
The dummy receiver optimization was reverted to enable the metadata-generated tear-off closures to be committed:
https://code.google.com/p/dart/source/detail?r=31414
A better fix for the incompatibility would have been to disable the dummy receiver optimization only for getters. I will do this.
Another way to fix the incompatibility is to make BoundClosures work properly when the dummy receiver optimization is in use.
There are three flavors of bound closure.
2 and #3 are currently folded together.
They can be made to work with the dummy receiver optimization in one of two ways:
(a) Have separate classes and don't store separate (and inconsistent) 'self' and 'receiver' values. Ensure that generated methods that pass the one value in both positions.
(b) Use one class as current, but canonicalize the closure on construction to have the same value for 'self' and 'receiver', in effect replacing the dummy receiver with the true receiver.
Care needs to be taken with mixins. A mixin is a regular class but may be mixed into a native class, requiring a separate receiver/interceptor.
The text was updated successfully, but these errors were encountered: