|
| 1 | +// RUN: %empty-directory(%t/src) |
| 2 | +// RUN: split-file %s %t/src |
| 3 | + |
| 4 | +// REQUIRES: swift_feature_NonisolatedNonsendingByDefault |
| 5 | + |
| 6 | +/// Build the library A |
| 7 | +// RUN: %target-swift-frontend -emit-module %t/src/A.swift \ |
| 8 | +// RUN: -module-name A -swift-version 6 -enable-library-evolution \ |
| 9 | +// RUN: -enable-upcoming-feature NonisolatedNonsendingByDefault \ |
| 10 | +// RUN: -emit-module-path %t/A.swiftmodule \ |
| 11 | +// RUN: -emit-module-interface-path %t/A.swiftinterface |
| 12 | + |
| 13 | +// RUN: %target-swift-typecheck-module-from-interface(%t/A.swiftinterface) -module-name A |
| 14 | + |
| 15 | +// Build the client using module |
| 16 | +// RUN: %target-swift-emit-sil -verify -module-name Client -I %t %t/src/Client.swift | %FileCheck %t/src/Client.swift |
| 17 | + |
| 18 | +// RUN: rm %t/A.swiftmodule |
| 19 | + |
| 20 | +// Re-build the client using interface |
| 21 | +// RUN: %target-swift-emit-sil -verify -module-name Client -I %t %t/src/Client.swift | %FileCheck %t/src/Client.swift |
| 22 | + |
| 23 | +//--- A.swift |
| 24 | +@MainActor |
| 25 | + |
| 26 | +public final class Test { |
| 27 | + public nonisolated func test() async {} |
| 28 | +} |
| 29 | + |
| 30 | +//--- Client.swift |
| 31 | +import A |
| 32 | + |
| 33 | +// CHECK-LABEL: sil hidden @$s6Client4test1ty1A4TestC_tYaF : $@convention(thin) @async (@guaranteed Test) -> () |
| 34 | +// CHECK: bb0([[SELF:%.*]] : $Test): |
| 35 | +// CHECK: [[MAIN_ACTOR_EXISTENTIAL:%.*]] = init_existential_ref %4 : $MainActor : $MainActor, $any Actor |
| 36 | +// CHECK: [[ANY_ACTOR:%.*]] = enum $Optional<any Actor>, #Optional.some!enumelt, [[MAIN_ACTOR_EXISTENTIAL]] |
| 37 | +// CHECK: [[TEST_METHOD:%.*]] = function_ref @$s1A4TestC4testyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional<any Actor>, @guaranteed Test) -> () |
| 38 | +// CHECK: apply [[TEST_METHOD]]([[ANY_ACTOR]], [[SELF]]) |
| 39 | +// CHECK: } // end sil function '$s6Client4test1ty1A4TestC_tYaF' |
| 40 | +@MainActor |
| 41 | +func test(t: Test) async { |
| 42 | + await t.test() // Ok |
| 43 | +} |
0 commit comments