-
-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inline constructor of abstracts #11526
Comments
cc @basro |
A quick note: This inlines everything: class P {
public var x : Float;
public inline function new(x) this.x = x;
}
@:forward
abstract PA(P) {
public inline function new(x) this = new P(x);
}
class Test {
static function foo(x:Int) {
var p1 = { v : new P(x) }
trace(p1.v.x);
var p2 = new PA(5);
trace(p2.x);
}
static function main() {
foo(5);
}
} |
I have not tested with the compiler but my bet is that the cancellation is happening in this line. It is likely that the type of the inlined object and the type of the field access are not strictly equal. |
Good intuition:
I don't know where that goes wrong though because the type is initially correct:
|
We recently changed our Heaps Vector implementation to use an abstract so we can have some operator overloading, but we noticed some regression due to constructor inline not being triggered anymore.
We can reproduce with the following sample:
It seems inline new is not handled for abstracts ?
The text was updated successfully, but these errors were encountered: