-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[WIP] [BUGFIX release] Ensure CP's are _super
wrapped.
#13242
Conversation
159d40e
to
1d77228
Compare
Lgtm, @krisselden r? |
This seems reasonable. |
@@ -102,8 +102,14 @@ function giveDescriptorSuper(meta, key, property, values, descs, base) { | |||
superProperty = superDesc; | |||
} | |||
|
|||
// add a default `_super` to ensure proper wraping if `_super` is used in `property` |
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.
wrapping
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.
Good catch! Updated...
Prior to this change, a CP that was not included in the superclass would not get re-wrapped. This means that when calling it from another function that is required to be super wrapped would set that other function as the `_super`. This changes to ensure that all descriptors are wrapped if they include `_super` (`hasSuper` check on platforms that support `Function.prototype.toString`).
1d77228
to
d3d2305
Compare
👍 for this one |
Prior to this, if a method was not included in the superclasses prototype, we would skip wrapping it with its own `_super`. However, that means that if the method is called from within another `_super` wrapped method it would not properly reset the `_super` causing incorrect results. This ensures that all methods are super wrapped if they contain `_super` (and `Function.prototype.toString` is present).
This also was an issue for normal methods (aka non-CP's). I fixed that and added an additional test for it. |
OK, so forcing wrapping of all functions that match the The following breaks:
One specific example is glimmer templates since they are now a class (and get instantiated) by the container, where you would have |
I can remove the last commit and land the fix for CP's (which seems less of a compat concern), but we need to decide what to do about the test added for normal method's:
When |
|
||
// only provide a super setter if the property has one already | ||
if (property._setter) { | ||
superProperty._setter = function() {}; |
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.
you should use the ROOT that wrap uses for this, so it is marked as not having super explicitly
It is non obvious to me that you should be able to call super without having a method you are overriding. I know we handled a case like this for mixins, after talking with @wycats this should have just been an error. I can't think of another language where you can call Also, the fix to hasSuper for CP macros I think was wrong, and I'm nervous about how many things will be wrapped by this PR, it seems like instead of the REGEX being loosened so much, that the macros themselves should have likely just passed |
@krisselden - Thanks for reviewing!
If that is true we should error not silently ignore/swallow the
Which fix?
I'm not certain what exactly this means, but we can discuss the first point on the next core team call to figure out a path forward. |
@rwjblue the fix I was referring to with CPs was loosening the REGEX for hasSuper to |
We had a long discussion about this during the last core team meeting (see notes here). The basic conclusions are:
Will continue to follow up with @krisselden and @wycats to figure out the right path forward for this... |
Thank you for taking the time to figure this out fellas. As of right now, is there a current workaround to check if a CP has a super? |
@offirgolan - Not really. I suppose you could do something like this, but it pretty much sucks. |
@rwjblue Yeah I see what you mean. I guess it could be an intermediate solution but if you are going to deprecate calling _super when the parent class doesn't have the method defined, I feel like there should be a helper method exposed to check that. |
@offirgolan - I think we will likely warn/deprecate/something. As @krisselden mentioned, most programming languages do not allow calling |
@rwjblue Ah okay totally understandable. Thanks for the clarification 😄 |
_super
wrapped._super
wrapped.
Closing in favor of #14780. |
Prior to this change, a CP that was not included in the superclass would not get re-wrapped. This means that when calling it from another function that is required to be super wrapped would set that other function as the
_super
.This changes to ensure that all descriptors are wrapped if they include
_super
(hasSuper
check on platforms that supportFunction.prototype.toString
).Fixes #13230.
/cc @stefanpenner