Skip to content

Conversation

@nathawes
Copy link
Contributor

@nathawes nathawes commented Oct 13, 2020

Also adjust the fallback context it choses now that ErrorExprs no longer cause constraint generation to fail, and provide the correct DeclContext of the fallback as well, rather than using the DeclContext of the original expression.

This PR also fixes some issues with the fallback logic in typeCheckForCodeCompletion:

  1. For completion expressions in multi-statement closures, we were assuming a separate typeCheckExpression call would be made when the outer expression produced a single solution that had a resolved type for the closure. If the solution contained other fixes unrelated to the closure however, it wasn't applied and a separate call for the body was never made.

  2. typeCheckForCodeCompletion sometimes falls through to normal expression type checking but didn't update the passed-in target's expression after sanitizing and prechecking it, which may have modified it and/or its sub-expressions. This triggered assertion failures in certain cases due to a stale top-level expression pointer being used with updated subexpressions.

…n when no typeCheckExpression call is made

...and adjust the fallback context it choses now that ErrorExprs no longer
cause constraint generation to fail.

Also fix some issues with the fallback logic in typeCheckForCodeCompletion:

1) For completion expressions in multi-statement closures, we were assuming a
separate typeCheckExpression call would be made when the outer expression
produced a single solution that had a resolved type for the closure. If the
solution contained other fixes unrelated to the closure however, it wasn't
applied and a separate call for the body was never made.

2) typeCheckForCodeComplation sometimes falls back to regular expression type
checking but didn't update the passed-in target's expression after santizing
and prechecking it, which may have modified it and its sub-expressions. This
triggered assertion failures in certain cases due to the mix of the stale
top-level expression pointer being used with updated subexpressions.
@nathawes nathawes requested review from rintaro and xedin October 13, 2020 01:42
@nathawes
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nathawes nathawes merged commit abd4608 into swiftlang:main Oct 13, 2020
@nathawes nathawes deleted the reuse-completion-context-finder-for-fallback-completion branch October 13, 2020 20:17
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.

3 participants