Files
swift-mirror/test/embedded/existential-class-bound4.swift
T
Erik Eckstein a3af80f37b IRGen: correctly get the base protocol conformance when emitting a specialized embedded witness table
This didn't work in case the base conformance is both, specialized and inherited

rdar://170096756
2026-03-10 13:40:07 +01:00

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