Files
swift-mirror/test/Concurrency/sendable_functions.swift
Daniel Rodríguez Troitiño ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00

48 lines
1.6 KiB
Swift

// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify %s -strict-concurrency=complete
// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify %s -strict-concurrency=complete
// RUN: %target-swift-frontend -emit-sil -o /dev/null -verify %s -strict-concurrency=complete -enable-upcoming-feature RegionBasedIsolation
// REQUIRES: concurrency
// REQUIRES: swift_feature_RegionBasedIsolation
@Sendable func globalFunc() { }
@available(SwiftStdlib 5.1, *)
actor A {
var state: Bool = false
@Sendable func f() { // expected-warning{{actor-isolated synchronous instance method 'f()' cannot be marked as '@Sendable'}}
state = true
}
@Sendable nonisolated func g() { }
@Sendable func fAsync() async {
state = true
}
}
class NonSendableC { // expected-note{{class 'NonSendableC' does not conform to the 'Sendable' protocol}}
var x: Int = 0
@Sendable func inc() { // expected-warning{{instance method of non-Sendable type 'NonSendableC' cannot be marked as '@Sendable'}}
x += 1
}
}
struct S<T> { // expected-note{{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
let t: T
@Sendable func test() {} // expected-warning{{instance method of non-Sendable type 'S<T>' cannot be marked as '@Sendable'}}
}
extension S: Sendable where T: Sendable {
@Sendable func test2() {}
}
@available(SwiftStdlib 5.1, *)
@MainActor @Sendable func globalActorFunc() { } // expected-warning{{main actor-isolated synchronous global function 'globalActorFunc()' cannot be marked as '@Sendable'}}
@available(SwiftStdlib 5.1, *)
@MainActor @Sendable func globalActorFuncAsync() async { }