mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This patch updates the `actor class` spelling to `actor` in almost all of the tests. There are places where I verify that we sanely handle `actor` as an attribute though. These include: - test/decl/class/actor/basic.swift - test/decl/protocol/special/Actor.swift - test/SourceKit/CursorInfo/cursor_info_concurrency.swift - test/attr/attr_objc_async.swift - test/ModuleInterface/actor_protocol.swift
58 lines
4.3 KiB
Swift
58 lines
4.3 KiB
Swift
// BEGIN MyModule.swift
|
|
public actor MyActor {
|
|
public func asyncFunc(fn: () async -> Void) async throws {}
|
|
}
|
|
|
|
func test(act: MyActor) async throws {
|
|
try await act.asyncFunc {}
|
|
}
|
|
|
|
public actor class MyActorClass {
|
|
public func asyncFunc(fn: () async -> Void) async throws {}
|
|
}
|
|
|
|
func test(act: MyActorClass) async throws {
|
|
try await act.asyncFunc {}
|
|
}
|
|
|
|
// BEGIN App.swift
|
|
import MyModule
|
|
|
|
func test(act: MyActor) async throws {
|
|
try await act.asyncFunc {}
|
|
}
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %{python} %utils/split_file.py -o %t %s
|
|
|
|
// RUN: %empty-directory(%t/Modules)
|
|
// RUN: %target-swift-frontend -emit-module -o %t/Modules/MyModule.swiftmodule -module-name MyModule %t/MyModule.swift -enable-experimental-concurrency
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=1:15 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=ACTOR %s
|
|
// RUN: %sourcekitd-test -req=cursor -pos=2:15 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=FUNC %s
|
|
// RUN: %sourcekitd-test -req=cursor -pos=5:16 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=ACTOR %s
|
|
// RUN: %sourcekitd-test -req=cursor -pos=6:19 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=FUNC %s
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=9:20 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=CLASSACTOR %s
|
|
// RUN: %sourcekitd-test -req=cursor -pos=13:16 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=CLASSACTOR %s
|
|
|
|
// ACTOR: <Declaration>public actor MyActor</Declaration>
|
|
// ACTOR: <decl.class><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>actor</syntaxtype.keyword> <decl.name>MyActor</decl.name></decl.class>
|
|
|
|
// CLASSACTOR: <Declaration>public actor class MyActorClass</Declaration>
|
|
// CLASSACTOR: <decl.class><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>actor</syntaxtype.keyword> <syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>MyActorClass</decl.name></decl.class>
|
|
|
|
// FUNC: <Declaration>public func asyncFunc(fn: () async -> <Type usr="s:s4Voida">Void</Type>) async throws</Declaration>
|
|
// FUNC: <decl.function.method.instance><syntaxtype.keyword>public</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>asyncFunc</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>fn</decl.var.parameter.argument_label>: <decl.var.parameter.type>() <syntaxtype.keyword>async</syntaxtype.keyword> -> <decl.function.returntype><ref.typealias usr="s:s4Voida">Void</ref.typealias></decl.function.returntype></decl.var.parameter.type></decl.var.parameter>) <syntaxtype.keyword>async</syntaxtype.keyword> <syntaxtype.keyword>throws</syntaxtype.keyword></decl.function.method.instance>
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=3:16 %t/App.swift -- %t/App.swift -target %target-triple -I %t/Modules -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=ACTOR_XMOD %s
|
|
// RUN: %sourcekitd-test -req=cursor -pos=4:19 %t/App.swift -- %t/App.swift -target %target-triple -I %t/Modules -Xfrontend -enable-experimental-concurrency | %FileCheck -check-prefix=FUNC_XMOD %s
|
|
|
|
// ACTOR_XMOD: <Declaration>actor MyActor</Declaration>
|
|
// ACTOR_XMOD: <decl.class><syntaxtype.keyword>actor</syntaxtype.keyword> <decl.name>MyActor</decl.name></decl.class>
|
|
|
|
// FUNC_XMOD: <Declaration>func asyncFunc(fn: () async -> <Type usr="s:s4Voida">Void</Type>) async throws</Declaration>
|
|
// FUNC_XMOD: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>asyncFunc</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>fn</decl.var.parameter.argument_label>: <decl.var.parameter.type>() <syntaxtype.keyword>async</syntaxtype.keyword> -> <decl.function.returntype><ref.typealias usr="s:s4Voida">Void</ref.typealias></decl.function.returntype></decl.var.parameter.type></decl.var.parameter>) <syntaxtype.keyword>async</syntaxtype.keyword> <syntaxtype.keyword>throws</syntaxtype.keyword></decl.function.method.instance>
|