mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
While matching two metatypes where one side is a class (which could have supertypes) and another is a type variable use `subtype` constraint to delay binding types together because there is a real possibility that there exists a superclass associated with yet free type variable which would be a better match when attempted. Resolves: rdar://problem/44816848
17 lines
338 B
Swift
17 lines
338 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
class A {}
|
|
class B: A {}
|
|
class C: A {}
|
|
|
|
struct S {
|
|
func foo<T: A>(types: [T.Type]) {}
|
|
}
|
|
|
|
func bar(_ s: S, _ forced_s: S!) {
|
|
s.foo(types: [A.self, B.self]) // ok
|
|
s.foo(types: [B.self, A.self]) // ok
|
|
forced_s.foo(types: [A.self, B.self]) // ok
|
|
forced_s.foo(types: [B.self, A.self]) // ok
|
|
}
|