-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ensure analyzer allows desugaring iterable of callable type in for-each to a function type #47471
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
Comments
A for-in statement is specified in terms of desugaring. The When the iterable is |
Thanks @eernstg I will re-word this issue then; the analyzer does not do any desugaring, as far as I know; as I'm rewriting how we do implicit tear-off conversion, I think analayzer's behavior will chang to not allow this conversion in a for-each, which would be a bug. |
That's could very well be the best approach anyway, because an actual desugaring could make it harder to report errors in a way that makes sense in terms of the original source code. So I think it makes sense to look at the desugaring, conclude that certain errors must be reported or certain coercions must be applied to the original code as such, and then apply those checks/coercions to the original source code. (We could then claim that the whole thing should have been written without the use of syntactic sugar in the first place, but I'm not 100% sure about that either, because a desugaring specification can be a compact and readable way to specify the treatment of certain constructs. We do try to keep desugaring to a minimum in the spec, anyway ;-) |
(Analyzer allows this too)
Take this program:
The spec says:
I understand why the first is allowed:
c /*1*/
has a static type which is an interface type with acall
method, and a context type which is a function type.I don't understand why the second is allowed. In
void Function() f in iterable
, there is no expression whose static type is an interface type that has a method namedcall
.Analyzer allows this too but I'm considering it a bug that should be fixed.
The text was updated successfully, but these errors were encountered: