-
Notifications
You must be signed in to change notification settings - Fork 205
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
Consider removing support for null-aware explicit extension invocations #4201
Comments
@eernstg further commented:
|
It is not a compile-time error, and it's working as intended and specified. As I remember it (vaguely, but it's coming back), this was a deliberate way to allow the explicit invocation to represent the same thing as the implicit extension invocation Without this rule, there is no (easy) way to rewrite The meaning of The text predates null-safety, so one can't read the main text and assume that it talks about nullable types. The referenced text is for pre-null-safety types where the corresponding constructor invocation With null safety, the corresponding constructor invocation would be on the promoted value, and should only be an error if
The spec was ready for null safety with the modifications needed in separate sections, and the implementations are implementing the intended NNBD-behavior correctly. It's all good. (If we had a null-safety aware spec, it should be saying the same thing, otherwise that's a spec bug). |
@eernstg points out in dart-lang/sdk#59654 (comment) that according to the spec, a null-aware explicit extension invocation such as
E(c)?.g...
is a compile-time error.As far as I can tell, both the analyzer and the CFE have supported this behavior since the inception of the "extension methods" feature. Here is a link to the text from the original feature specification suggesting that this was intended to be supported: https://github.com/dart-lang/language/blob/main/accepted/2.7/static-extension-methods/feature-specification.md#null-aware-member-invocations
I'm moving discussion about this from dart-lang/sdk#59654 to here, since (a) dart-lang/sdk#59654 is about a specific problem with flow analysis and the analyzer, and (b) the change being proposed is a change to the behavior of both implementations, and so even if we decide to make this change in order to bring the implementations in line with existing specification text, I think we should treat it as a language change.
The text was updated successfully, but these errors were encountered: