Skip to content

[embedded] Add a test showcasing class method runtime dispatch #69291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions test/embedded/class-func.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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

// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx

@main
struct Main {
static func main() {
let array: [MyClass] = [MyClass(), MySubclass()]
for e in array {
e.method()
}
}
}

class MyClass {
func method() { Self.foo() }

class func foo() { print("MyClass.foo") }
}

class MySubclass: MyClass {

override class func foo() { print("MySubclass.foo") }
}

// CHECK: MyClass.foo
// CHECK: MySubclass.foo