mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
a3af80f37b
This didn't work in case the base conformance is both, specialized and inherited rdar://170096756
56 lines
1.3 KiB
Swift
56 lines
1.3 KiB
Swift
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo %target-embedded-posix-shim) | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: optimized_stdlib
|
|
// REQUIRES: OS=macosx || OS=linux-gnu || OS=wasip1
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
public protocol Base: AnyObject {
|
|
func foo()
|
|
}
|
|
|
|
protocol ClassBound: Base {
|
|
func bar()
|
|
}
|
|
|
|
class MyGenericClass<T> {
|
|
var typ: String
|
|
init(typ: String) { self.typ = typ }
|
|
}
|
|
extension MyGenericClass: ClassBound {
|
|
func foo() { print("MyGenericClass<\(typ)>.foo()") }
|
|
func bar() { print("MyGenericClass<\(typ)>.bar()") }
|
|
}
|
|
|
|
final class Derived: MyGenericClass<Int> {
|
|
init() {
|
|
super.init(typ: "Int")
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct Main {
|
|
static func main() {
|
|
var array: [any ClassBound] = []
|
|
array.append(MyGenericClass<Int>(typ: "Int"))
|
|
array.append(MyGenericClass<String>(typ: "String"))
|
|
array.append(Derived())
|
|
|
|
for e in array {
|
|
e.foo()
|
|
e.bar()
|
|
}
|
|
|
|
// CHECK: MyGenericClass<Int>.foo()
|
|
// CHECK: MyGenericClass<Int>.bar()
|
|
|
|
// CHECK: MyGenericClass<String>.foo()
|
|
// CHECK: MyGenericClass<String>.bar()
|
|
|
|
// CHECK: MyGenericClass<Int>.foo()
|
|
// CHECK: MyGenericClass<Int>.bar()
|
|
}
|
|
}
|
|
|