Skip to content

Commit eaa38f3

Browse files
committed
Sema: Fix a fuzzer crash
This test case crashes when prepared overloads are disabled, but passes when enabled. To avoid messing up tests if we have to turn the flag on and off, fix the crash.
1 parent 3c3f6e7 commit eaa38f3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,8 +2924,10 @@ static bool diagnoseContextualFunctionCallGenericAmbiguity(
29242924
// from all the closure contextual fix/solutions and if there are more than
29252925
// one fixed type diagnose it.
29262926
swift::SmallSetVector<Type, 4> genericParamInferredTypes;
2927-
for (auto &fix : contextualFixes)
2928-
genericParamInferredTypes.insert(fix.first->getFixedType(resultTypeVar));
2927+
for (auto &fix : contextualFixes) {
2928+
if (fix.first->hasFixedType(resultTypeVar))
2929+
genericParamInferredTypes.insert(fix.first->getFixedType(resultTypeVar));
2930+
}
29292931

29302932
if (llvm::all_of(allFixes, [&](FixInContext fix) {
29312933
auto fixLocator = fix.second->getLocator();

validation-test/compiler_crashers/Solution-getFixedType-98b9c4.swift renamed to validation-test/compiler_crashers_fixed/Solution-getFixedType-98b9c4.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// {"kind":"typecheck","signature":"swift::constraints::Solution::getFixedType(swift::TypeVariableType*) const","signatureAssert":"Assertion failed: (knownBinding != typeBindings.end()), function getFixedType"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
class a {
44
static
55
b {

0 commit comments

Comments
 (0)