Skip to content

[TypeChecker] Re-work type-checking of string interpolations #61746

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

Closed
wants to merge 12 commits into from

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Oct 26, 2022

Type-check tap expressions the same way as we do closures. As soon as tap
expression gets a (contextual) type assigned - generate constraints for its
body (using conjunction constraint for incremental solving) and apply solution to
the body inline instead of using typeCheckTapBody.

@xedin
Copy link
Contributor Author

xedin commented Oct 26, 2022

This is still a draft because I need to to work out a few issues when string interpolations are used in closures (conjunction could get disconnected from the rest of the constraint system).

@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from 47576fe to 2aee1c4 Compare December 24, 2022 00:38
@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from 2aee1c4 to 6d01bdd Compare January 3, 2023 09:13
@xedin
Copy link
Contributor Author

xedin commented Jan 3, 2023

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Jan 3, 2023

@ahoppen Looks like the only thing that is left here are IDE work, would you mind looking into that when you have a chance?

@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from 6d01bdd to 6695006 Compare February 13, 2023 23:34
@xedin
Copy link
Contributor Author

xedin commented Feb 13, 2023

@swift-ci please smoke test

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Feb 14, 2023

@swift-ci please smoke test

@ahoppen ahoppen force-pushed the rework-typechecking-of-tap-exprs branch 2 times, most recently from 399fcc5 to 7dc34c8 Compare February 14, 2023 15:04
@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2023

@swift-ci Please smoke test

@ahoppen
Copy link
Member

ahoppen commented Feb 14, 2023

@swift-ci Please SourceKit stress test

@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from 7dc34c8 to d1db590 Compare February 15, 2023 05:36
@xedin
Copy link
Contributor Author

xedin commented Feb 15, 2023

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Feb 15, 2023

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 10, 2023

@swift-ci please smoke test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Mar 10, 2023

@swift-ci please test source compatibility

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Mar 10, 2023

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 10, 2023

@swift-ci please smoke test macOS platform

@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from 820e2ea to 415cc77 Compare March 15, 2023 17:50
@xedin
Copy link
Contributor Author

xedin commented Mar 15, 2023

@swift-ci please test source compatibility

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Mar 15, 2023

@swift-ci please test source compatibility

@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from eb517da to c3e0a83 Compare March 22, 2023 00:44
@xedin
Copy link
Contributor Author

xedin commented Mar 22, 2023

@swift-ci please test source compatibility

@ahoppen
Copy link
Member

ahoppen commented Mar 23, 2023

@swift-ci Please smoke test macOS

xedin and others added 10 commits March 27, 2023 09:24
Generate a conjunction for each tap expression body as soon as it
gets a contextual type instead of separate post-factum type-checking
via `typeCheckTapBody`.
It doesn't need access to anything besides external declarations
which could be brought into the scope by context analyzer.
Since interpolations are now type-checked using conjunctions
these diagnostics could be rank as part of the root expression
or statement verification.
`test/Constraints/interpolation_segments.swift` has been removed
because interpolations are now type-checked together with their
context, so the separate type-checking test no longer applies.
…eserve connection to context

Since "tap" bodies are now type-checked together with the context,
it's imperative that the variable that represents an interpolation
never gets disconnected from its context in the constraint system,
otherwise it wouldn't be possible to determine types for the
references.
@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from c3e0a83 to 15eaca2 Compare March 27, 2023 18:05
@xedin
Copy link
Contributor Author

xedin commented Mar 27, 2023

@swift-ci Please smoke test macOS

@xedin
Copy link
Contributor Author

xedin commented Mar 27, 2023

@swift-ci please test source compatibility

…ectly

`TapExpr` do not form their own declaration context which means
that using `context.getAsDeclContext` is incorrect for them.
@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from 15eaca2 to f245b2b Compare March 27, 2023 20:56
@xedin
Copy link
Contributor Author

xedin commented Mar 27, 2023

@swift-ci Please smoke test macOS

@xedin
Copy link
Contributor Author

xedin commented Mar 27, 2023

@swift-ci please test source compatibility

… closures

Both single- and multi-statement closures now use variable reference
collector to identify variables used in the interpolation body, which
means that it's not longer necessary to connect to the closure explicitly
(if interpolation is contained in one).
@xedin xedin force-pushed the rework-typechecking-of-tap-exprs branch from f245b2b to f9ec1e6 Compare March 28, 2023 16:40
@xedin
Copy link
Contributor Author

xedin commented Mar 28, 2023

@swift-ci please smoke test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Mar 28, 2023

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Mar 30, 2023

Closing in favor of #63717

@xedin xedin closed this Mar 30, 2023
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.

2 participants