Skip to content

Commit 8514d7b

Browse files
committed
[CS] Don't simplify FunctionResult in simplifyLocator
Simplifying into the function expression is wrong, like `FunctionArgument` this isn't an element that can be simplified.
1 parent 9468ee7 commit 8514d7b

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,8 +3389,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
33893389
continue;
33903390
}
33913391

3392-
case ConstraintLocator::ApplyFunction:
3393-
case ConstraintLocator::FunctionResult:
3392+
case ConstraintLocator::ApplyFunction: {
33943393
// Extract application function.
33953394
if (auto applyExpr = getAsExpr<ApplyExpr>(anchor)) {
33963395
anchor = applyExpr->getFn();
@@ -3412,7 +3411,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
34123411
}
34133412

34143413
break;
3415-
3414+
}
34163415
case ConstraintLocator::AutoclosureResult:
34173416
case ConstraintLocator::LValueConversion:
34183417
case ConstraintLocator::DynamicType:
@@ -3677,6 +3676,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
36773676
case ConstraintLocator::SynthesizedArgument:
36783677
break;
36793678

3679+
case ConstraintLocator::FunctionResult:
36803680
case ConstraintLocator::DynamicLookupResult:
36813681
case ConstraintLocator::KeyPathComponentResult:
36823682
break;

test/Constraints/issue-78376.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-typecheck-verify-swift %clang-importer-sdk
2+
3+
// REQUIRES: objc_interop
4+
5+
import Foundation
6+
import CoreGraphics
7+
8+
func foo(_ x: Double) {}
9+
func bar() -> Double { 0 }
10+
11+
// https://github.com/swiftlang/swift/issues/78376
12+
let _: (CGFloat) -> Void = foo
13+
// expected-error@-1 {{cannot convert value of type '(Double) -> ()' to specified type '(CGFloat) -> Void'}}
14+
let _: () -> CGFloat = bar
15+
// expected-error@-1 {{cannot convert value of type '() -> Double' to specified type '() -> CGFloat'}}

0 commit comments

Comments
 (0)