Skip to content

[ConstraintSystem] Enable pack element type reprs in expressions. #62713

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
merged 10 commits into from
Dec 21, 2022

Conversation

hborla
Copy link
Member

@hborla hborla commented Dec 20, 2022

Enable pack element type reprs in expressions by plumbing a callback through type resolution that will generate a PackElementOf constraint when resolving a PackReferenceTypeRepr. The OpenPackElementType function object is created during constraint generation, and ultimately TypeReprs and TypeExprs inside pack expansion expressions will have an opened pack element type. If such type reprs appear outside pack expansions, type resolution will report an error.

…traint

when resolving pack reference type reprs inside pack expansion expressions.
…' type

reprs to be pack expansion expressions.
…tType instead

of assigning it to std::function_ref.

std::function_ref does not own the function reference, so assigning an OpenPackElementType
to a local function_ref lead to stale constraint system references when invoking
operator () later on.
@hborla hborla requested a review from xedin December 20, 2022 21:35
…onstraints

rather than relying on PackElementExprs collected by preCheck.

This handles pack element expressions and pack element type reprs, and enforces that
all packs expanded by a given pack expansion expression all have the same shape.

Once the parser creates PackExpansionExpr directly (based on a dedicated syntax instead
of postfix '...'), the code in preCheck for identifying and creating pack expansions
can simply be deleted.
@hborla hborla marked this pull request as ready for review December 21, 2022 04:08
@hborla
Copy link
Member Author

hborla commented Dec 21, 2022

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Dec 21, 2022

@swift-ci please smoke test

@hborla hborla merged commit 42ede18 into swiftlang:main Dec 21, 2022
@hborla hborla deleted the open-pack-element-type-repr branch December 21, 2022 15:48
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