mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If key path capability is not yet determined it cannot be favored over a conjunction because: 1. There could be no other bindings and that would mean that key path would be selected even though it's not yet ready. 2. A conjunction could be the source of type context for the key path. Resolves: rdar://119055010
44 lines
788 B
Swift
44 lines
788 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// rdar://119055010 - greedy key path type assignment breaks keypath-to-function conversion
|
|
|
|
protocol Executable {}
|
|
|
|
final class Wrapper<Value> {
|
|
func update<Return>(_ work: (inout Value) throws -> Return) rethrows -> Return {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
enum Lookup<Value> {
|
|
func flatMap<T>(_ transform: (Value) throws -> Lookup<T>) rethrows -> Lookup<T> { fatalError() }
|
|
}
|
|
|
|
protocol Entry {
|
|
}
|
|
|
|
extension Entry {
|
|
var executable: Lookup<any Executable> {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
func lookup() -> Lookup<any Entry> {
|
|
fatalError()
|
|
}
|
|
|
|
struct Test {
|
|
struct Data {
|
|
}
|
|
|
|
let value = Wrapper<Data>()
|
|
|
|
func run() -> Lookup<any Executable> {
|
|
value.update { data in
|
|
let _ = 42
|
|
return lookup()
|
|
}
|
|
.flatMap(\.executable)
|
|
}
|
|
}
|