Files
swift-mirror/test/Constraints/rdar44816848.swift
Pavel Yaskevich 28a66a23eb [CSSimplify] Delay binding metatype instance types if one side is type variable
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
2018-11-27 14:36:46 -08:00

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
}