mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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. This also means we don't need to handle it in `MissingCallFailure`, since we shouldn't be recording that fix in this case.
This commit is contained in:
@@ -3903,14 +3903,6 @@ bool MissingCallFailure::diagnoseAsError() {
|
||||
return true;
|
||||
}
|
||||
|
||||
case ConstraintLocator::FunctionResult: {
|
||||
path = path.drop_back();
|
||||
if (path.back().getKind() != ConstraintLocator::AutoclosureResult)
|
||||
break;
|
||||
|
||||
LLVM_FALLTHROUGH;
|
||||
}
|
||||
|
||||
case ConstraintLocator::AutoclosureResult: {
|
||||
auto loc = getConstraintLocator(getRawAnchor(), path.drop_back());
|
||||
AutoClosureForwardingFailure failure(getSolution(), loc);
|
||||
|
||||
@@ -3389,8 +3389,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
|
||||
continue;
|
||||
}
|
||||
|
||||
case ConstraintLocator::ApplyFunction:
|
||||
case ConstraintLocator::FunctionResult:
|
||||
case ConstraintLocator::ApplyFunction: {
|
||||
// Extract application function.
|
||||
if (auto applyExpr = getAsExpr<ApplyExpr>(anchor)) {
|
||||
anchor = applyExpr->getFn();
|
||||
@@ -3412,7 +3411,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case ConstraintLocator::AutoclosureResult:
|
||||
case ConstraintLocator::LValueConversion:
|
||||
case ConstraintLocator::DynamicType:
|
||||
@@ -3677,6 +3676,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
|
||||
case ConstraintLocator::SynthesizedArgument:
|
||||
break;
|
||||
|
||||
case ConstraintLocator::FunctionResult:
|
||||
case ConstraintLocator::DynamicLookupResult:
|
||||
case ConstraintLocator::KeyPathComponentResult:
|
||||
break;
|
||||
|
||||
15
test/Constraints/issue-78376.swift
Normal file
15
test/Constraints/issue-78376.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
// RUN: %target-typecheck-verify-swift %clang-importer-sdk
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
import Foundation
|
||||
import CoreGraphics
|
||||
|
||||
func foo(_ x: Double) {}
|
||||
func bar() -> Double { 0 }
|
||||
|
||||
// https://github.com/swiftlang/swift/issues/78376
|
||||
let _: (CGFloat) -> Void = foo
|
||||
// expected-error@-1 {{cannot convert value of type '(Double) -> ()' to specified type '(CGFloat) -> Void'}}
|
||||
let _: () -> CGFloat = bar
|
||||
// expected-error@-1 {{cannot convert value of type '() -> Double' to specified type '() -> CGFloat'}}
|
||||
Reference in New Issue
Block a user