@@ -737,6 +737,12 @@ static CanSILFunctionType getSILFunctionType(SILModule &M,
737
737
// from the function to which the argument is attached.
738
738
if (constant && !constant->isDefaultArgGenerator ())
739
739
if (auto function = constant->getAnyFunctionRef ()) {
740
+ auto getCanonicalType = [&](Type t) -> CanType {
741
+ if (genericSig)
742
+ return genericSig->getCanonicalTypeInContext (t, *M.getSwiftModule ());
743
+ return t->getCanonicalType ();
744
+ };
745
+
740
746
auto &Types = M.Types ;
741
747
auto loweredCaptures = Types.getLoweredLocalCaptures (*function);
742
748
@@ -745,22 +751,21 @@ static CanSILFunctionType getSILFunctionType(SILModule &M,
745
751
ParameterConvention convention = ParameterConvention::Direct_Unowned;
746
752
auto selfMetatype = MetatypeType::get (
747
753
loweredCaptures.getDynamicSelfType ()->getSelfType (),
748
- MetatypeRepresentation::Thick)
749
- -> getCanonicalType ();
750
- SILParameterInfo param (selfMetatype , convention);
754
+ MetatypeRepresentation::Thick);
755
+ auto canSelfMetatype = getCanonicalType (selfMetatype );
756
+ SILParameterInfo param (canSelfMetatype , convention);
751
757
inputs.push_back (param);
752
758
753
759
continue ;
754
760
}
755
761
756
762
auto *VD = capture.getDecl ();
757
- auto type = VD->getType ()->getCanonicalType ();
758
-
759
- type = ArchetypeBuilder::mapTypeOutOfContext (
760
- function->getAsDeclContext (), type)->getCanonicalType ();
761
-
763
+ auto type = ArchetypeBuilder::mapTypeOutOfContext (
764
+ function->getAsDeclContext (), VD->getType ());
765
+ auto canType = getCanonicalType (type);
766
+
762
767
auto &loweredTL = Types.getTypeLowering (
763
- AbstractionPattern (genericSig, type ), type );
768
+ AbstractionPattern (genericSig, canType ), canType );
764
769
auto loweredTy = loweredTL.getLoweredType ();
765
770
switch (Types.getDeclCaptureKind (capture)) {
766
771
case CaptureKind::None:
0 commit comments