-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove generalized tear-offs #27518
Comments
@bwilkerson I believe there's analyzer work as well (not strictly required, since it's behind a flag). Correct? |
Thanks, added one for that too. |
Moving to 1.22 per release discussion, deprecation warning will happen in 1.21 (see #27742). |
Marking spec update complete in the checklist up top. |
Part of the reason for lack of use may have been that constructor tear-offs were not considered const: class A {}
void main() {
const c = new A#; // error: expression is not a valid compile-time constant
} This made it impossible to use such tear-offs as factories in the version of Angular's DI system that demands constants. See #24845. munificent, you said in that issue that we don't have to worry about that issue because this tear-off feature is being removed, but that may be circular reasoning: That issue made tear-offs unattractive => the feature wasn't used much => you think you should remove the feature => we should keep tear-offs unattractive. |
My logic isn't that I think we should remove generalized tear-offs. That decision has already been made. The logic is thus: This issue relies on generalized tear-offs → Generalized tear-offs are being removed → We can close this issue. :) The larger picture here is that the language team does want to add a better story for:
Generalized tear-offs handled the former, but with a not great syntax. It only handled a subset of the latter, again with a not great syntax. In some of the cases it did handle, the result was more verbose than an explicit closure, again because of the not great We think we have some ideas on how to do something notably better than generalized tear-offs. And, since they weren't in use anyway, we decided to remove them to simplify things and avoid having multiple overlapping ways to accomplish the same thing. |
Oh, to your original comment about canonicalization. If/when we introduce syntax for constructor tear-offs, we'll take canonicalization into account. I don't have a lot of expertise on it, but we'll make sure there's time to iterate on it with the Angular folks and users like yourself so that we don't ship a feature that doesn't handle important use cases. |
Marking VM complete. |
Changelog updated in #28221 |
All done, closing! |
The language team has decided the generalized tear-off feature looks like it won't work as well as originally hoped, so we're going to take it out. Fortunately, it was never fully implemented and it appears to be completely unused within Google (both strong signs it wasn't a highly desired feature).
In the future, we hope to support constructor tear-offs with a more natural syntax. In the meantime, the tools that have implemented generalized tear-offs should remove support for it.
Tracking issues:
The text was updated successfully, but these errors were encountered: