Skip to content

Commit b7e322d

Browse files
committed
[Diagnostics] Fix crash in diagnoseSubscriptErrors
If there is a single candidate with a valid index type, don't assume that such candidate always has a valid function type. There are multiple examples of this crash we've seen but there is no reproducer test-case unfortunately. Resolves: rdar://problem/37565861
1 parent 149ad71 commit b7e322d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4640,10 +4640,12 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
46404640
UncurriedCandidate cand = calleeInfo.candidates[0];
46414641
auto candType = baseType->getTypeOfMember(CS.DC->getParentModule(),
46424642
cand.getDecl(), nullptr);
4643-
auto paramsType = candType->getAs<FunctionType>()->getInput();
4644-
if (!typeCheckChildIndependently(indexExpr, paramsType,
4645-
CTP_CallArgument, TCC_ForceRecheck))
4646-
return true;
4643+
if (auto *candFunc = candType->getAs<FunctionType>()) {
4644+
auto paramsType = candFunc->getInput();
4645+
if (!typeCheckChildIndependently(
4646+
indexExpr, paramsType, CTP_CallArgument, TCC_ForceRecheck))
4647+
return true;
4648+
}
46474649
}
46484650
}
46494651

0 commit comments

Comments
 (0)