- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathexperimental_feature_strictconcurrency.swift
38 lines (29 loc) · 1.39 KB
/
experimental_feature_strictconcurrency.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-experimental-feature StrictConcurrency -emit-sil -o /dev/null -verify %s
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-experimental-feature StrictConcurrency=complete -emit-sil -o /dev/null -verify %s
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -enable-upcoming-feature StrictConcurrency -emit-sil -o /dev/null -verify %s
// REQUIRES: concurrency
// REQUIRES: swift_feature_StrictConcurrency
classC1{} // expected-note{{class 'C1' does not conform to the 'Sendable' protocol}}
classC2{}
@available(*, unavailable)
extensionC2:Sendable{} // expected-note{{conformance of 'C2' to 'Sendable' has been explicitly marked unavailable here}}
protocolTestProtocol{
associatedtypeValue:Sendable
}
structTest1:TestProtocol{ // expected-warning{{type 'Test1.Value' (aka 'C1') does not conform to the 'Sendable' protocol}}
typealiasValue=C1
}
structTest2:TestProtocol{ // expected-warning{{conformance of 'C2' to 'Sendable' is unavailable}}
// expected-note@-1{{in associated type 'Self.Value' (inferred as 'C2')}}
typealiasValue=C2
}
@MainActor
func iterate(stream:AsyncStream<Int>)async{
nonisolated(unsafe)varit= stream.makeAsyncIterator()
whilelet element =await it.next(){
print(element)
}
forawaitxin stream {
print(x)
}
}