-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Teach SubstitutionMap::isIdentity about non-canonical generic params #25767
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
Can you think of any other interesting test cases that I didn't include? @swift-ci Please test |
Build failed |
lib/AST/SubstitutionMap.cpp
Outdated
return; | ||
|
||
unsigned ordinal = sig->getGenericParamOrdinal(paramTy); | ||
auto replacement = getReplacementTypes()[ordinal]->getCanonicalType(sig); |
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 think it would be clearer if you just did Type(paramTy).subst(this)
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.
That's not the same check, is it? That would also accept SubstitutionMaps that didn't have an entry for that parameter.
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.
SubstitutionMaps are always "complete". There's an entry for each parameter
lib/AST/SubstitutionMap.cpp
Outdated
}); | ||
|
||
return !hasNonIdentityReplacement && | ||
countOfGenericParams == getReplacementTypes().size(); |
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.
Is it ever possible for countOfGenericParams to not equal getReplacementTypes().size()? Maybe it should be an assertion instead?
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 was wondering that, but I didn't know if it was safe. All valid SubstitutionMaps should behave like that, but what about a degenerate one?
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.
See above :)
Build failed |
d2d6631
to
5b8eeb7
Compare
@swift-ci Please test |
Build failed |
Build failed |
5b8eeb7
to
c1f08ec
Compare
@swift-ci Please smoke test |
Do a weaker check here that only looks at the canonical generic params and guarantees that *those* substitute to themselves. There may be replacement types for other generic params too, to canonicalize them, but that's not a problem. This fixes a crash trying to mangle decls with opaque result types that have generic signatures that canonicalize away a generic parameter. rdar://problem/51775857
c1f08ec
to
d46aa9a
Compare
@swift-ci Please smoke test |
…wiftlang#25767) Do a weaker check here that only looks at the canonical generic params and guarantees that *those* substitute to themselves. There may be replacement types for other generic params too, to canonicalize them, but that's not a problem. This fixes a crash trying to mangle decls with opaque result types that have generic signatures that canonicalize away a generic parameter. rdar://problem/51775857 (cherry picked from commit 8157ccf)
Do a weaker check here that only looks at the canonical generic params and guarantees that those substitute to themselves. There may be replacement types for other generic params too, to canonicalize them, but that's not a problem.
This fixes a crash trying to mangle decls with opaque result types that have generic signatures that canonicalize away a generic parameter.
rdar://problem/51775857