Files
swift-mirror/test/Constraints/rdar66234725.swift
Pavel Yaskevich d19c2ccc02 [CSBindings] Don't attempt to rank unviable bindings
If a type variable doesn't have any "direct" bindings let's not
consider it as viable to be attempted next. Such type variables
are helps purely to accommodate transitive binding inference
for other members of subtype chain.

Resolves: rdar://problem/66234725
2020-07-30 16:35:31 -07:00

29 lines
553 B
Swift

// RUN: %target-typecheck-verify-swift
protocol P {}
protocol Func {
associatedtype Result
init()
mutating func update<D: P>(data: D)
func finalize() -> Result
}
struct S<T: P, F: Func> {
var arr: [T]
func test() -> [F.Result] {
return stride(from: 0, to: arr.endIndex, by: 2).map {
(arr[$0], $0 < arr.index(before: arr.endIndex) ? arr[$0.advanced(by: 1)] : nil) // Ok
}.map { (lhs, rhs) -> F.Result in
var fun = F()
fun.update(data: lhs)
fun.update(data: rhs!)
return fun.finalize()
}
}
}