@@ -1016,6 +1016,7 @@ static Type substOpaqueTypesWithUnderlyingTypesRec(
1016
1016
// / opaque substitutions are or are not allowed.
1017
1017
static bool canSubstituteTypeInto (Type ty, const DeclContext *dc,
1018
1018
OpaqueSubstitutionKind kind,
1019
+ ResilienceExpansion contextExpansion,
1019
1020
bool isContextWholeModule) {
1020
1021
TypeDecl *typeDecl = ty->getAnyNominal ();
1021
1022
if (!typeDecl) {
@@ -1056,7 +1057,8 @@ static bool canSubstituteTypeInto(Type ty, const DeclContext *dc,
1056
1057
1057
1058
case OpaqueSubstitutionKind::SubstituteNonResilientModule:
1058
1059
// 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)
1060
1062
return typeDecl->getEffectiveAccess () > AccessLevel::FilePrivate;
1061
1063
1062
1064
return typeDecl->getEffectiveAccess () > AccessLevel::Internal;
@@ -1100,10 +1102,13 @@ operator()(SubstitutableType *maybeOpaqueType) const {
1100
1102
// context.
1101
1103
auto inContext = this ->getContext ();
1102
1104
auto isContextWholeModule = this ->isWholeModule ();
1105
+ auto contextExpansion = this ->contextExpansion ;
1103
1106
if (inContext &&
1104
1107
partialSubstTy.findIf (
1105
- [inContext, substitutionKind, isContextWholeModule](Type t) -> bool {
1108
+ [inContext, substitutionKind, isContextWholeModule,
1109
+ contextExpansion](Type t) -> bool {
1106
1110
if (!canSubstituteTypeInto (t, inContext, substitutionKind,
1111
+ contextExpansion,
1107
1112
isContextWholeModule))
1108
1113
return true ;
1109
1114
return false ;
@@ -1211,9 +1216,12 @@ operator()(CanType maybeOpaqueType, Type replacementType,
1211
1216
// context.
1212
1217
auto inContext = this ->getContext ();
1213
1218
auto isContextWholeModule = this ->isWholeModule ();
1219
+ auto contextExpansion = this ->contextExpansion ;
1214
1220
if (partialSubstTy.findIf (
1215
- [inContext, substitutionKind, isContextWholeModule](Type t) -> bool {
1221
+ [inContext, substitutionKind, isContextWholeModule,
1222
+ contextExpansion](Type t) -> bool {
1216
1223
if (!canSubstituteTypeInto (t, inContext, substitutionKind,
1224
+ contextExpansion,
1217
1225
isContextWholeModule))
1218
1226
return true ;
1219
1227
return false ;
0 commit comments