-
Notifications
You must be signed in to change notification settings - Fork 201
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
Can't pass an inflight closure to a super
ctor call
#4925
Comments
There is already a Construct with name 'Derived' in $Root [Default]
Hi, This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Another simpler case of this (by EladB): class Foo {
pub bar() {
inflight () => {};
}
}
let f = new Foo();
f.bar();
f.bar(); Update: this issue is a different issue and is a dup of #2853. See details for specific issue below. |
Detailed problem descriptionPassing an inflight closure to a
Thoughts about fixing thisOne alternative is getting rid of inflight closure transformation altogether (see #5033). But if we want to avoid that at this point here are some other thoughts:
|
super
ctor call
See #4925 We can now code-gen inflight closures without construct id conflicts. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Related: #6387 |
…t used (#6531) This is a small code cleanup as part of addressing #4925. We only generate the `parent_this` variable used in generated closure classes when needed. If the inflight closure never accesses `this` then we don't generated `parent_this`. The code avoids traversing into inner classes inside the closure when searching for `this` accesses, making it a bit cleaner and more efficient. This relates to #4925 because it solves the problem of accessing `this` (for assignment into `parent_this`) before the `super()` call in a ctor. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
…6535) This is part of the effort to address #4925. Because inflight closures turn into class definitions, when they are passed to a `super()` call we use to get an error telling us that `super()` must be the first statement in a ctor. Now this is fixed: ```wing class Foo { new(x: num) {} } class Bar extends Foo { new() { class Baz {} // This is now ok super(1); } } ``` This PR also improves the diagnostics for mssing super calls or "not first statement" super calls. note: waiting for #6531 to be merged first. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
…call (#6599) fixes #4925 Now you can pass inflight closures and also any `new PreflightClass()` as parameters to a `super()` call in a ctor. What I did is detect these cases and made sure the implicit scope passed to the construct ctor is `$scope` and not `this` which isn't available before `super()` is called. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Congrats! 🚀 This was released in Wing 0.74.30. |
…call (#6599) fixes #4925 Now you can pass inflight closures and also any `new PreflightClass()` as parameters to a `super()` call in a ctor. What I did is detect these cases and made sure the implicit scope passed to the construct ctor is `$scope` and not `this` which isn't available before `super()` is called. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
I tried this:
This happened:
I expected this:
To work
Is there a workaround?
No response
Component
Compiler
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Anything else?
No response
Community Notes
The text was updated successfully, but these errors were encountered: