-
-
Notifications
You must be signed in to change notification settings - Fork 670
Rework constructor handling #446
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
Conversation
Alright, this is passing the tests now. Changes:
Other notes:
|
@@ -1023,150 +1022,175 @@ export class Compiler extends DiagnosticEmitter { | |||
return typeRef; | |||
} | |||
|
|||
/** Compiles just the body of a function in whatever is the current context. */ | |||
private compileFunctionBody(instance: Function): ExpressionRef[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one isn't strictly necessary now that I've gone another route, but who knows what it might be good for in the future.
LGTM. Is it possible inline constructors for now? |
Inlining constructors seems to be limited in usefulness, except for the One special case is if there's no declared constructor, which in turn isn't decorated |
Yeah, I mean declare constructor with forced decorator |
Turns out that inlining constructors that didn't return a custom value never worked due to this check preventing it, BUT I think I can at least make the |
Merging, continuing from here :) |
As a follow-up to #445 this PR aims at reworking constructor handling. Currently, whenever a
new
is encountered, it calls the constructor if it is present and if it isn't, inlines a bare allocation with field initializers at that place. While we could get away with this, generating actual constructors for classes that don't explicitly define one would simplify fixing some remaining issues, while also reducing code size (inlined allocation and initializers quickly accumulate), instead of just working around them.