Skip to content

Commit e5b1f7b

Browse files
committed
[AST] TypeSubstitution: Add a nullptr check before attempting to use inContext
This fixes a crash in `ReplaceOpaqueTypesWithUnderlyingTypes::operator()` that I couldn't properly reduce because it has to do with `SwiftDeclCollector`. `ReplaceOpaqueTypesWithUnderlyingTypes::operator()` has the check already and `canSubstituteTypeInto` expects `inContext` to be non-null. Resolves: rdar://156896331
1 parent 597aaba commit e5b1f7b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,8 @@ operator()(InFlightSubstitution &IFS, Type maybeOpaqueType,
11571157
auto inContext = this->getContext();
11581158
auto isContextWholeModule = this->isWholeModule();
11591159
auto contextExpansion = this->contextExpansion;
1160-
if (partialSubstTy.findIf(
1160+
if (inContext &&
1161+
partialSubstTy.findIf(
11611162
[inContext, substitutionKind, isContextWholeModule,
11621163
contextExpansion](Type t) -> bool {
11631164
if (!canSubstituteTypeInto(t, inContext, substitutionKind,

0 commit comments

Comments
 (0)