Skip to content

Preliminary constraint solver support for variadic generics #61465

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 21 commits into from
Oct 17, 2022

Conversation

slavapestov
Copy link
Contributor

No description provided.

@slavapestov slavapestov force-pushed the variadic-generics-constraints branch from 4d747da to bdc8169 Compare October 6, 2022 03:43
@slavapestov slavapestov force-pushed the variadic-generics-constraints branch 2 times, most recently from 5d8f3a2 to 4476813 Compare October 14, 2022 19:24
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov marked this pull request as ready for review October 14, 2022 20:49
The expression type checker replaces type variables with UnresolvedType
and PlaceholderType sometimes, so allow them to appear here.
I'm also going to use it in TypeMatcher, for the Requirement Machine's
same-type requirement desugaring.
@slavapestov slavapestov force-pushed the variadic-generics-constraints branch from 4476813 to b9d7201 Compare October 17, 2022 01:38
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 7c3a63b into swiftlang:main Oct 17, 2022
auto *packType = cast<PackType>(desugar2);

if (packExpansionType->getPatternType()->is<TypeVariableType>())
return matchTypes(packExpansionType->getPatternType(), packType, kind, subflags, locator);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the idea here is that we'd like to resolve a pattern type of expansion using a pack type (type2) but at the same we don't want to double-check the matching if the pattern is already resolved? Could there be a situation when either pattern or pack type are only partially resolved and need matching to facilitate further inference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a hack to work around other problems in PackExpansionMatcher.cpp. This chunk of code was removed in subsequent PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! I'll working through the list :)


bool TupleType::containsPackExpansionType() const {
for (auto elt : getElements()) {
if (elt.getType()->is<PackExpansionType>())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not make this a property of a tuple type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea. I wanted to wait to micro-optimize until more code is fleshed out though.

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