mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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).
21 lines
424 B
Swift
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)
|
|
}
|