Skip to content

Commit 713c76b

Browse files
authored
Merge pull request swiftlang#32278 from hamishknight/nullable-ptr
[CS] Add a missing null check in repairFailures
2 parents 617189f + a487767 commit 713c76b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,11 +3047,12 @@ bool ConstraintSystem::repairFailures(
30473047
// default values, let's see whether error is related to missing
30483048
// explicit call.
30493049
if (fnType->getNumParams() > 0) {
3050-
auto anchor = simplifyLocatorToAnchor(getConstraintLocator(locator));
3051-
if (!anchor.is<Expr *>())
3050+
auto *loc = getConstraintLocator(locator);
3051+
auto *anchor = getAsExpr(simplifyLocatorToAnchor(loc));
3052+
if (!anchor)
30523053
return false;
30533054

3054-
auto overload = findSelectedOverloadFor(getAsExpr(anchor));
3055+
auto overload = findSelectedOverloadFor(anchor);
30553056
if (!(overload && overload->choice.isDecl()))
30563057
return false;
30573058

test/Constraints/sr12964.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol P {}
4+
typealias T = (P) -> Void
5+
let x: T! = [1, 2, 3].reversed().reduce()
6+
// expected-error@-1 {{no exact matches in call to instance method 'reduce'}}
7+
// expected-note@-2 2{{candidate has partially matching parameter list}}

0 commit comments

Comments
 (0)