@@ -1755,9 +1755,14 @@ static CanAnyFunctionType getDefaultArgGeneratorInterfaceType(
17551755 }
17561756
17571757 // Get the generic signature from the surrounding context.
1758- auto funcInfo = TC.getConstantInfo (SILDeclRef (VD));
1759- return CanAnyFunctionType::get (funcInfo.FormalType .getOptGenericSignature (),
1760- {}, canResultTy);
1758+ CanGenericSignature sig;
1759+ if (auto *afd = dyn_cast<AbstractFunctionDecl>(VD)) {
1760+ auto funcInfo = TC.getConstantInfo (SILDeclRef (VD));
1761+ sig = funcInfo.FormalType .getOptGenericSignature ();
1762+ } else {
1763+ sig = TC.getEffectiveGenericSignature (DC);
1764+ }
1765+ return CanAnyFunctionType::get (sig, {}, canResultTy);
17611766}
17621767
17631768// / Get the type of a stored property initializer, () -> T.
@@ -1940,7 +1945,8 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) {
19401945 return getGlobalAccessorType (var->getInterfaceType ()->getCanonicalType ());
19411946 }
19421947 case SILDeclRef::Kind::DefaultArgGenerator:
1943- return getDefaultArgGeneratorInterfaceType (*this , vd, vd->getDeclContext (),
1948+ return getDefaultArgGeneratorInterfaceType (*this , vd,
1949+ vd->getInnermostDeclContext (),
19441950 c.defaultArgIndex );
19451951 case SILDeclRef::Kind::StoredPropertyInitializer:
19461952 return getStoredPropertyInitializerInterfaceType (*this ,
@@ -1995,7 +2001,10 @@ TypeConverter::getConstantGenericEnvironment(SILDeclRef c) {
19952001 return cast<ClassDecl>(vd)->getGenericEnvironmentOfContext ();
19962002 case SILDeclRef::Kind::DefaultArgGenerator:
19972003 // Use the generic environment of the original function.
1998- return getConstantGenericEnvironment (SILDeclRef (c.getDecl ()));
2004+ if (auto *afd = dyn_cast<AbstractFunctionDecl>(c.getDecl ()))
2005+ return getConstantGenericEnvironment (SILDeclRef (c.getDecl ()));
2006+ return c.getDecl ()->getInnermostDeclContext ()
2007+ ->getGenericEnvironmentOfContext ();
19992008 case SILDeclRef::Kind::StoredPropertyInitializer:
20002009 // Use the generic environment of the containing type.
20012010 return c.getDecl ()->getDeclContext ()->getGenericEnvironmentOfContext ();
0 commit comments