mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When bindings are picked for particular type variable, right-hand side of the binding might be another type variable wrapped into optional type, when trying to determine if both sides of the binding have the same l-valueness it's imperative to look throught optional type of the right-hand side. Otherwise new binding might be effectively unsolvable. Resolves: rdar://problem/37291371
22 lines
410 B
Swift
22 lines
410 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
extension Collection where Element: Numeric {
|
|
var v: Element {
|
|
return self.reduce(0, +)
|
|
}
|
|
}
|
|
|
|
struct R<T> {}
|
|
func ==<T: Equatable>(lhs: R<T>, rhs: T?) {}
|
|
|
|
func foo<T>(_ e: @autoclosure @escaping () throws -> T?) -> R<T> {
|
|
return R<T>()
|
|
}
|
|
|
|
func bar<T>(_ e: T?) -> R<T> {
|
|
return R<T>()
|
|
}
|
|
|
|
foo([Double(1.0)].v) == Double(1.0)
|
|
bar([Double(1.0)].v) == Double(1.0)
|