mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We currently leave a key path constraint unsolved if one of its components hasn't yet had its overload resolved. However, for e.g a missing member component, the overload type variable will be bound to a hole and an overload will never be resolved. Tweak the logic to consider the key path constraint trivially solved if one of its components has been marked as a hole, which will allow the key path type itself to be marked as a hole. Resolves SR-12437 & SR-12823. Resolves rdar://62201037.
32 lines
617 B
Swift
32 lines
617 B
Swift
// RUN: %target-swift-frontend %s -verify -emit-sil -o /dev/null
|
|
|
|
struct R<T> {
|
|
var str: String?
|
|
}
|
|
|
|
func map<A, B>(e: (A) -> B) -> () -> R<B> {
|
|
fatalError()
|
|
}
|
|
func map<A, B>(_ : (A) -> B) -> (A?) -> B? {
|
|
fatalError()
|
|
}
|
|
|
|
infix operator |>
|
|
func |> <A, B> (g: A, h: (A) -> B) -> B { h(g) }
|
|
|
|
infix operator ^^^
|
|
func ^^^ <A, B, C>(j: ((B) -> C) -> A, k: String) {}
|
|
|
|
extension WritableKeyPath {
|
|
static func ^^^ (l: WritableKeyPath, m: Value) -> (Root) -> Root {
|
|
fatalError()
|
|
}
|
|
}
|
|
|
|
func foo<T>(_ s: String, _ rt: R<T>?) -> String? {
|
|
return rt.flatMap { _ in
|
|
rt |> map(\.str ^^^ s)
|
|
}
|
|
.flatMap(\.str)
|
|
}
|