mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In many places, we're interested in whether a type with archetypes *might be* a superclass of another type with the right bindings, particularly in the optimizer. Provide a separate Type::isBindableToSuperclassOf method that performs this check. Use it in the devirtualizer to fix rdar://problem/24993618. Using it might unblock other places where the optimizer is conservative, but we can fix those separately.
17 lines
448 B
Swift
17 lines
448 B
Swift
// RUN: %target-swift-frontend %s -parse -verify
|
|
|
|
class Base<T> { }
|
|
class Derived: Base<Int> { }
|
|
|
|
func foo<T where T: Base<Int>, T: Derived>(x: T) -> Derived {
|
|
return x
|
|
}
|
|
|
|
// FIXME: Should not be an error
|
|
// expected-error@+1{{cannot be a subclass of both 'Base<T>' and 'Derived'}}
|
|
func bar<T, U where U: Base<T>, U: Derived>(x: U, y: T) -> (Derived, Int) {
|
|
// FIXME
|
|
// expected-error@+1{{cannot convert return expression}}
|
|
return (x, y)
|
|
}
|