-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Fix a couple of issues related to generic specialization #66971
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
Conversation
…ric typealiases If type alias declaration doesn't add new generic parameters refer to its underlying type to find them.
…ete type Diagnose attempts to specialize a concrete type or its alias: ```swift struct Test {} typealias X = Test _ = X<Int>() // error ```
The situations where number of parameters and arguments didn't match.
…f generic arguments ```swift struct Test<T, U> {} _ = Test<Int>() // error ```
…valid number of arguments
@swift-ci please test |
@swift-ci please clean test macOS platform |
lib/Sema/CSSimplify.cpp
Outdated
return nullptr; | ||
|
||
auto genericParams = genericContext->getGenericParams(); | ||
if (!genericParams || genericParams->size() == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can have a non-null generic parameter list with zero parameters in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the original check but I can simplify it down to just !genericParams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
lib/Sema/CSSimplify.cpp
Outdated
if (auto *TA = dyn_cast<TypeAliasDecl>(decl)) { | ||
if (TA->isGeneric()) | ||
return nullptr; | ||
if (auto underlying = TA->getUnderlyingType()->getAnyNominal()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about checking if TA->getUnderlyingType()-is<UnboundGenericType>()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other places I saw check for isGeneric but I can change if that’s better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slavapestov I made it AnyGenericType
to make it possible to properly diagnose cases like typealias Print = Printer<Any>
, using UnboundGenericType
won't work because we'd just return nullptr
and following logic would just return SolutionKind::Solved
and I don't want to mess with that in this PR.
@swift-ci please test |
Resolves: rdar://111239949