Files
swift-mirror/test/Constraints/sr7875.swift
Mark Lacey 54b2504699 [ConstraintSystem] Fix a logic error in computing potential bindings.
A change was made to attempt to use constraints that we have between
type variables to inform potential bindings, such that if we have:
   $T1 <: $T2
we would use $T1's bindings to add to the bindings of $T2. This is
only valid if we're adding bindings where $T1 is the supertype,
though, otherwise we could have the constraints:
  $T1 <: $T2
  $T1 <: X
imply that $T2 is a supertype of X, which doesn't make sense.

Fixes rdar://problem/40810000 (aka https://bugs.swift.org/browse/SR-7875).
2018-06-18 18:33:30 -07:00

21 lines
424 B
Swift

// RUN: %target-typecheck-verify-swift
protocol Proto {}
class Base {}
class Test : Base, Proto {}
struct A {}
struct B {}
func overloaded<T: Proto & Base>(_ f: () -> T, _ g: (T, A) -> ()) {}
func overloaded<T: Proto & Base>(_ f: () -> T, _ g: (T, B) -> ()) {}
func f() -> Test { return Test() }
func g<T: Proto & Base>(_ t: T, _ a: A) -> () {}
func test() {
overloaded(f, g as (Test, A) -> ())
overloaded(f, g)
}