Files
swift-mirror/test/Constraints/generic_super_constraint.swift
Joe Groff 77dd9b2992 Split exact-subclass and bindable-to-subclass queries.
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.
2016-03-09 11:14:45 -08:00

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)
}