-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
actor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featureslet & varFeature: constant and variable declarationsFeature: constant and variable declarationsstatic declarationsFeature → declarations: Static declarationsFeature → declarations: Static declarationsswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
| Previous ID | SR-16009 |
| Radar | rdar://problem/90436577 |
| Original Reporter | @kavon |
| Type | Bug |
Environment
swift-driver version: 1.26.9 Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, Concurrency |
| Assignee | @kavon |
| Priority | Medium |
md5: f6b9b747f9f450df4eddd1f7c0fe8e4f
cloned from:
Issue Description:
@MainActor
struct Bar {
init() {
print("bar init is main", Thread.isMainThread)
}
func barCall() {
print("bar call is main", Thread.isMainThread)
}
}
@MainActor
struct Foo {
@MainActor
static let global = Foo()
init() {
print("foo init is main", Thread.isMainThread)
let b = Bar()
b.barCall()
}
func fooCall() {
print("foo call is main", Thread.isMainThread)
}
}
Task.detached {
await Foo.global.fooCall()
}
// prints:
// foo init is main false
// bar init is main false
// bar call is main false
// foo call is main trueWhile fooCall() is enforced on the main thread, the initialization of the static variable is not, which breaks the contract of @MainActor.
Metadata
Metadata
Assignees
Labels
actor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featureslet & varFeature: constant and variable declarationsFeature: constant and variable declarationsstatic declarationsFeature → declarations: Static declarationsFeature → declarations: Static declarationsswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output