Skip to content

Commit a9d5f60

Browse files
committed
Revert "[Actor isolation] Limit propagation of unsafe global actors to instance members"
This reverts commit 61b22f8.
1 parent d4112f8 commit a9d5f60

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,16 +2674,8 @@ ActorIsolation ActorIsolationRequest::evaluate(
26742674
// If the declaration is in a nominal type (or extension thereof) that
26752675
// has isolation, use that.
26762676
if (auto selfTypeDecl = value->getDeclContext()->getSelfNominalTypeDecl()) {
2677-
if (auto selfTypeIsolation = getActorIsolation(selfTypeDecl)) {
2678-
// Don't propagate implicit, unsafe global actor isolation from a type
2679-
// to non-imported instance members.
2680-
if (selfTypeIsolation != ActorIsolation::GlobalActorUnsafe ||
2681-
value->getClangNode() ||
2682-
(selfTypeDecl->getGlobalActorAttr() &&
2683-
!selfTypeDecl->getGlobalActorAttr()->first->isImplicit())) {
2684-
return inferredIsolation(selfTypeIsolation);
2685-
}
2686-
}
2677+
if (auto selfTypeIsolation = getActorIsolation(selfTypeDecl))
2678+
return inferredIsolation(selfTypeIsolation);
26872679
}
26882680
}
26892681

test/ClangImporter/objc_async.swift

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Foundation
66
import ObjCConcurrency
77

8-
@MainActor func onlyOnMainActor() { } // expected-note{{calls to global function 'onlyOnMainActor()' from outside of its actor context are implicitly asynchronous}}
8+
@MainActor func onlyOnMainActor() { }
99

1010
func testSlowServer(slowServer: SlowServer) async throws {
1111
let _: Int = await slowServer.doSomethingSlow("mail")
@@ -130,8 +130,6 @@ struct SomeGlobalActor {
130130
static let shared = SomeActor()
131131
}
132132

133-
@SomeGlobalActor(unsafe) func unsafelyOnSomeGlobal() { }
134-
135133
class MyButton : NXButton {
136134
@MainActor func testMain() {
137135
onButtonPress() // okay
@@ -141,29 +139,11 @@ class MyButton : NXButton {
141139
onButtonPress() // expected-error{{instance method 'onButtonPress()' isolated to global actor 'MainActor' can not be referenced from different global actor 'SomeGlobalActor'}}
142140
}
143141

144-
func test() { // expected-note{{add '@MainActor' to make instance method 'test()' part of global actor 'MainActor'}}
145-
onButtonPress() // okay, onButtonPress is @MainActor(unsafe)
146-
unsafelyOnSomeGlobal() // okay, we haven't opted into anything
147-
onlyOnMainActor() // expected-error{{global function 'onlyOnMainActor()' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
148-
}
149-
}
150-
151-
class MyOtherButton: NXButton {
152-
override func onButtonPress() { // expected-note{{calls to instance method 'onButtonPress()' from outside of its actor context are implicitly asynchronous}}
153-
onlyOnMainActor() // yes, we're on the main actor
154-
unsafelyOnSomeGlobal() // okay, we haven't opted into any actual checking
155-
}
156-
157142
func test() {
158-
onButtonPress() // okay, it's @MainActor(unsafe)
159-
}
160-
161-
@SomeGlobalActor func testOther() {
162-
onButtonPress() // expected-error{{instance method 'onButtonPress()' isolated to global actor 'MainActor' can not be referenced from different global actor 'SomeGlobalActor' in a synchronous context}}
143+
onButtonPress() // okay
163144
}
164145
}
165146

166-
167147
func testButtons(mb: MyButton) {
168148
mb.onButtonPress()
169149
}

0 commit comments

Comments
 (0)