Skip to content

[TypeChecker] Re-land fixes/improvements related to SE-0326 #40397

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

Merged

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Dec 3, 2021

This re-lands almost everything from #39989 expect to test-case adjustments and
enabling inference by default.

xedin added 14 commits December 3, 2021 10:53
…ambiguous

If there are multiple overloads and all of them require closure
to have a parameter, let's diagnose that as such instead of
ambiguity.
…d code

While building a closure to inject `checkExpect` code, clone member
references associated with assignment. Re-using AST nodes is generally
invalid. This is visible with multi-statement closure inference enabled,
because the body is type-checked together with enclosing context
and both elements end up sharing `DeclRefExpr` and `MemberRefExpr`s.
This preserves previous behavior where multi-statement closures
where always type-checked without context.
…es when inference is enabled

When multi-statement closure inference is enabled it's body is
type-checked together with enclosing context, so they could be
walked directly just like single-expressions ones.
… closures

Extract diagnostic into a method and use it while type-checking
`for-in` in top-level code and in closures.
…t inference is enabled

Scope down previous check to avoid walking into patterns that appear
in multi-statement closures if the inference is enabled.
Preserve pre SE-0326 for code completion, so it could be ported
gradually.
Put some common logic related to local declaration to the base
class and refactor other walkers to use it instead of `ASTWalker`.
…ic parameter holes

Closure result type or generic parameter associated with such a location
could bw inferred from a body of a multi-statement closure (when inference
is enabled), so we need to give closure a chance to run before attemtping
a hole for such positions in diagnostic mode.
…Unchecked` flag

Propagate `LeaveClosureBodyUnchecked` flag from `typeCheckASTNodeAtLoc`
down to declaration checker to skip checking closures associated with
pattern binding entry initializers. This is no-op until multi-statement
inference becomes enabled by default.
Each of the elements in the result builder has to be fully pre-checked
now that multi-statement inference has been enabled.
@xedin
Copy link
Contributor Author

xedin commented Dec 3, 2021

@swift-ci please smoke test

@xedin xedin merged commit 8953c09 into swiftlang:main Dec 6, 2021
ahoppen added a commit to ahoppen/swift-source-compat-suite that referenced this pull request Dec 9, 2021
Add SR-15495 again (probably caused by swiftlang/swift#40397)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant