-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Support partial generic specialization of closures #7938
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
Support partial generic specialization of closures #7938
Conversation
…ecialized function in the context of a new generic signature
@swift-ci please smoke test |
lib/SILOptimizer/Utils/Generics.cpp
Outdated
@@ -130,10 +130,15 @@ bool ReabstractionInfo::prepareAndCheck(ApplySite Apply, SILFunction *Callee, | |||
bool HasConcreteGenericParams = false; | |||
bool HasNonArchetypeGenericParams = false; | |||
HasUnboundGenericParams = false; | |||
for (auto DT : CalleeGenericSig->getGenericParams()) { | |||
auto *SM = Apply.getModule().getSwiftModule(); | |||
for (auto GP : CalleeGenericSig->getGenericParams()) { |
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.
Instead you can call GenericSignature::getSubstitutableParams(), which skips those that are concrete
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.
Oh, nice that we have this API now.
lib/SILOptimizer/Utils/Generics.cpp
Outdated
@@ -382,6 +388,12 @@ ReabstractionInfo::createSubstitutedType(SILFunction *OrigF, | |||
Lowering::GenericContextScope GenericScope(M.Types, | |||
CanSpecializedGenericSig); | |||
FnTy = OrigF->getLoweredFunctionType()->substGenericArgs(M, SubstMap); | |||
// Some of the added new requirements may not have been taken into account |
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.
Can you add a FIXME here so that I can remember to remove this when I check in my fix?
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.
You have a fix for this?
Looks good, thanks! |
235846c
to
d85013e
Compare
@swift-ci please smoke test |
Clean-up the code and fix a bug on the way.