@@ -1009,6 +1009,7 @@ static Type substOpaqueTypesWithUnderlyingTypesRec(
10091009// / opaque substitutions are or are not allowed.
10101010static bool canSubstituteTypeInto (Type ty, const DeclContext *dc,
10111011 OpaqueSubstitutionKind kind,
1012+ ResilienceExpansion contextExpansion,
10121013 bool isContextWholeModule) {
10131014 TypeDecl *typeDecl = ty->getAnyNominal ();
10141015 if (!typeDecl) {
@@ -1049,7 +1050,8 @@ static bool canSubstituteTypeInto(Type ty, const DeclContext *dc,
10491050
10501051 case OpaqueSubstitutionKind::SubstituteNonResilientModule:
10511052 // Can't access types that are not public from a different module.
1052- if (dc->getParentModule () == typeDecl->getDeclContext ()->getParentModule ())
1053+ if (dc->getParentModule () == typeDecl->getDeclContext ()->getParentModule () &&
1054+ contextExpansion != ResilienceExpansion::Minimal)
10531055 return typeDecl->getEffectiveAccess () > AccessLevel::FilePrivate;
10541056
10551057 return typeDecl->getEffectiveAccess () > AccessLevel::Internal;
@@ -1093,10 +1095,13 @@ operator()(SubstitutableType *maybeOpaqueType) const {
10931095 // context.
10941096 auto inContext = this ->getContext ();
10951097 auto isContextWholeModule = this ->isWholeModule ();
1098+ auto contextExpansion = this ->contextExpansion ;
10961099 if (inContext &&
10971100 partialSubstTy.findIf (
1098- [inContext, substitutionKind, isContextWholeModule](Type t) -> bool {
1101+ [inContext, substitutionKind, isContextWholeModule,
1102+ contextExpansion](Type t) -> bool {
10991103 if (!canSubstituteTypeInto (t, inContext, substitutionKind,
1104+ contextExpansion,
11001105 isContextWholeModule))
11011106 return true ;
11021107 return false ;
@@ -1204,9 +1209,12 @@ operator()(CanType maybeOpaqueType, Type replacementType,
12041209 // context.
12051210 auto inContext = this ->getContext ();
12061211 auto isContextWholeModule = this ->isWholeModule ();
1212+ auto contextExpansion = this ->contextExpansion ;
12071213 if (partialSubstTy.findIf (
1208- [inContext, substitutionKind, isContextWholeModule](Type t) -> bool {
1214+ [inContext, substitutionKind, isContextWholeModule,
1215+ contextExpansion](Type t) -> bool {
12091216 if (!canSubstituteTypeInto (t, inContext, substitutionKind,
1217+ contextExpansion,
12101218 isContextWholeModule))
12111219 return true ;
12121220 return false ;
0 commit comments