Skip to content

Commit 9e6e3fc

Browse files
committed
[embedded] Add a test showcasing class method runtime dispatch
1 parent 251becb commit 9e6e3fc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/embedded/class-func.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %target-run-simple-swift(%S/Inputs/print.swift -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
2+
3+
// REQUIRES: executable_test
4+
// REQUIRES: optimized_stdlib
5+
// REQUIRES: VENDOR=apple
6+
// REQUIRES: OS=macosx
7+
8+
@main
9+
struct Main {
10+
static func main() {
11+
let array: [MyClass] = [MyClass(), MySubclass()]
12+
for e in array {
13+
e.method()
14+
}
15+
}
16+
}
17+
18+
class MyClass {
19+
func method() { Self.foo() }
20+
21+
class func foo() { print("MyClass.foo") }
22+
}
23+
24+
class MySubclass: MyClass {
25+
26+
override class func foo() { print("MySubclass.foo") }
27+
}
28+
29+
// CHECK: MyClass.foo
30+
// CHECK: MySubclass.foo

0 commit comments

Comments
 (0)