Skip to content

Commit 987b2c9

Browse files
authored
Merge pull request #27593 from brentdax/dissolved-in-a-solution
Fix SE-0249 source compatibility break
2 parents ca8871e + 932128e commit 987b2c9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6397,6 +6397,7 @@ ConstraintSystem::simplifyKeyPathConstraint(
63976397

63986398
auto loc = locator.getBaseLocator();
63996399
if (definitelyFunctionType) {
6400+
increaseScore(SK_FunctionConversion);
64006401
return SolutionKind::Solved;
64016402
} else if (!anyComponentsUnresolved ||
64026403
(definitelyKeyPathType && capability == ReadOnly)) {

test/Constraints/keypath.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,23 @@ class Foo {
8282
func testFoo<T: Foo>(_: T) {
8383
let _: X<T> = .init(foo: \.optBar!.optWibble?.boolProperty)
8484
}
85+
86+
// rdar://problem/56131416
87+
88+
enum Rdar56131416 {
89+
struct Pass<T> {}
90+
static func f<T, U>(_ value: T, _ prop: KeyPath<T, U>) -> Pass<U> { fatalError() }
91+
92+
struct Fail<T> {}
93+
static func f<T, U>(_ value: T, _ transform: (T) -> U) -> Fail<U> { fatalError() }
94+
95+
static func takesCorrectType(_: Pass<UInt>) {}
96+
}
97+
98+
func rdar56131416() {
99+
// This call should not be ambiguous.
100+
let result = Rdar56131416.f(1, \.magnitude) // no-error
101+
102+
// This type should be selected correctly.
103+
Rdar56131416.takesCorrectType(result)
104+
}

0 commit comments

Comments
 (0)