Files
swift-mirror/test/Constraints/rdar62201037.swift
Hamish Knight aa0ad55706 [CS] Don't leave key path with holes unsolved
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.
2020-05-16 16:52:35 -07:00

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)
}