@@ -1016,6 +1016,7 @@ static Type substOpaqueTypesWithUnderlyingTypesRec(
10161016// / opaque substitutions are or are not allowed.
10171017static bool canSubstituteTypeInto (Type ty, const DeclContext *dc,
10181018 OpaqueSubstitutionKind kind,
1019+ ResilienceExpansion contextExpansion,
10191020 bool isContextWholeModule) {
10201021 TypeDecl *typeDecl = ty->getAnyNominal ();
10211022 if (!typeDecl) {
@@ -1056,7 +1057,8 @@ static bool canSubstituteTypeInto(Type ty, const DeclContext *dc,
10561057
10571058 case OpaqueSubstitutionKind::SubstituteNonResilientModule:
10581059 // Can't access types that are not public from a different module.
1059- if (dc->getParentModule () == typeDecl->getDeclContext ()->getParentModule ())
1060+ if (dc->getParentModule () == typeDecl->getDeclContext ()->getParentModule () &&
1061+ contextExpansion != ResilienceExpansion::Minimal)
10601062 return typeDecl->getEffectiveAccess () > AccessLevel::FilePrivate;
10611063
10621064 return typeDecl->getEffectiveAccess () > AccessLevel::Internal;
@@ -1100,10 +1102,13 @@ operator()(SubstitutableType *maybeOpaqueType) const {
11001102 // context.
11011103 auto inContext = this ->getContext ();
11021104 auto isContextWholeModule = this ->isWholeModule ();
1105+ auto contextExpansion = this ->contextExpansion ;
11031106 if (inContext &&
11041107 partialSubstTy.findIf (
1105- [inContext, substitutionKind, isContextWholeModule](Type t) -> bool {
1108+ [inContext, substitutionKind, isContextWholeModule,
1109+ contextExpansion](Type t) -> bool {
11061110 if (!canSubstituteTypeInto (t, inContext, substitutionKind,
1111+ contextExpansion,
11071112 isContextWholeModule))
11081113 return true ;
11091114 return false ;
@@ -1211,9 +1216,12 @@ operator()(CanType maybeOpaqueType, Type replacementType,
12111216 // context.
12121217 auto inContext = this ->getContext ();
12131218 auto isContextWholeModule = this ->isWholeModule ();
1219+ auto contextExpansion = this ->contextExpansion ;
12141220 if (partialSubstTy.findIf (
1215- [inContext, substitutionKind, isContextWholeModule](Type t) -> bool {
1221+ [inContext, substitutionKind, isContextWholeModule,
1222+ contextExpansion](Type t) -> bool {
12161223 if (!canSubstituteTypeInto (t, inContext, substitutionKind,
1224+ contextExpansion,
12171225 isContextWholeModule))
12181226 return true ;
12191227 return false ;
0 commit comments