-
Notifications
You must be signed in to change notification settings - Fork 217
Make function literal return type inference infer void from context #1092
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
Conversation
When I run my analyzer CL, this breaks many Note, that there are also failures in Flutter. |
@scheglov This was intended to be a null safety only change, but in looking at this PR again, I notice it wasn't specified as such. @eernstg we may want to clarify that. I think that may be the cause of the issues in flutter? The language tests look like legitimate breakages, for those you can approve and file an issue (@eernstg do you mind handling updating those)? @jakemac53 @kevmoo There's a possibility that this change, when fixed and landed (see the CL linked by @scheglov above) will break ported code. cc @davidmorgan as well for the heads up for when this rolls. Maybe we should consider doing a presubmit with the CL from @scheglov first to see if it will break anything? |
@scheglov wrote:
Yes, certainly. The breakages that I immediately expect are the following (where there is an error with a function declaration due to
Any test where a function literal has a context type whose return type has Comparing this to the CL results, I can see that Could it be that when the imposed return type schema of an @leafpetersen wrote:
Right, the PR changes inference.md, and that document had sentences like 'If the greatest closure of Looking again, it looks like most of inference.md does not refer to null-safety specific constructs. Do we need to adjust inference.md such that it specifically marks certain paragraphs as valid with null-safety and others as valid without null-safety, and the rest is valid for both? |
Test updates here. |
Implementation issues dart-lang/sdk#42720, dart-lang/sdk#42721. |
Thanks. If null safe only it's low risk for google3. If it applies everywhere, yes, we should presubmit :) |
Yep, the change was intended to be applied with null-safety only, and we just need to make sure the documents say so. Edit: Based on discussions with @leafpetersen, we won't introduce explicit disambiguation (to say: this rule applies with/without null-safety) into inference.md, because there is very little ambiguity in practice. |
@eernstg I do still think it's worth calling out this change (in the same way that the change in local function inference is called out). @davidmorgan are you worried about the possibility that this will break opted in third_party packages during the roll? |
dart-lang/language#1092 Bug: #42720 Change-Id: I7ce44a066382c63e22debbcb652a717b5230b267 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154620 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
Doesn't seem likely--should roll in on Monday. |
Sounds good, cf. #1102. |
Cf. #1063, in particular #1063 (comment).
This PR changes function literal return type inference to infer
void
from context (rather than using the bottom-up computed actual returned type when the context type isvoid
or, for anasync
function,Future<void>
and similar types likeFutureOr<void>?
). This means that the usual diagnostics emitted for void functions will now also be emitted for function literals passed where the context type has return typevoid
/Future<void>
.[Edit, clarification: Note that this change is only applicable with null-safety.]