Files
swift-mirror/test/Constraints/rdar37291371.swift
Pavel Yaskevich c6ff7b40cc [CSBindings] Look through optional types when trying to validate l-valueness of the new bindings
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
2018-02-08 01:55:39 -08:00

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)