Skip to content

Commit 2f2c194

Browse files
committed
Adopt 'nonisolated' in many tests, make sure its a modifier
1 parent f56ba59 commit 2f2c194

File tree

8 files changed

+24
-25
lines changed

8 files changed

+24
-25
lines changed

include/swift/AST/Attr.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,8 @@ DECL_ATTR(hasAsyncAlternative, HasAsyncAlternative,
631631
111)
632632

633633
CONTEXTUAL_SIMPLE_DECL_ATTR(nonisolated, Nonisolated,
634-
OnFunc | OnConstructor | OnVar | OnSubscript | ConcurrencyOnly |
634+
DeclModifier | OnFunc | OnConstructor | OnVar | OnSubscript |
635+
ConcurrencyOnly |
635636
ABIStableToAdd | ABIStableToRemove |
636637
APIBreakingToAdd | APIStableToRemove,
637638
112)

test/Concurrency/actor_isolation.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ func checkAsyncPropertyAccess() async {
9494
}
9595

9696
extension MyActor {
97-
@actorIndependent var actorIndependentVar: Int {
97+
nonisolated var actorIndependentVar: Int {
9898
get { 5 }
9999
set { }
100100
}
101101

102-
@actorIndependent func actorIndependentFunc(otherActor: MyActor) -> Int {
102+
nonisolated func actorIndependentFunc(otherActor: MyActor) -> Int {
103103
_ = immutable
104104
_ = mutable // expected-error{{actor-isolated property 'mutable' can not be referenced from an '@actorIndependent'}}
105105
_ = text[0] // expected-error{{actor-isolated property 'text' can not be referenced from an '@actorIndependent' context}}
@@ -593,22 +593,22 @@ actor LazyActor {
593593
lazy var l24: Int = self.l
594594
lazy var l25: Int = { [unowned self] in self.l }()
595595

596-
@actorIndependent lazy var l31: Int = { v }()
596+
nonisolated lazy var l31: Int = { v }()
597597
// expected-error@-1 {{actor-isolated property 'v' can not be referenced from an '@actorIndependent' context}}
598-
@actorIndependent lazy var l32: Int = v
598+
nonisolated lazy var l32: Int = v
599599
// expected-error@-1 {{actor-isolated property 'v' can not be referenced from an '@actorIndependent' context}}
600-
@actorIndependent lazy var l33: Int = { self.v }()
600+
nonisolated lazy var l33: Int = { self.v }()
601601
// expected-error@-1 {{actor-isolated property 'v' can not be referenced from an '@actorIndependent' context}}
602-
@actorIndependent lazy var l34: Int = self.v
602+
nonisolated lazy var l34: Int = self.v
603603
// expected-error@-1 {{actor-isolated property 'v' can not be referenced from an '@actorIndependent' context}}
604-
@actorIndependent lazy var l35: Int = { [unowned self] in self.v }()
604+
nonisolated lazy var l35: Int = { [unowned self] in self.v }()
605605
// expected-error@-1 {{actor-isolated property 'v' can not be referenced from an '@actorIndependent' context}}
606606

607-
@actorIndependent lazy var l41: Int = { l }()
608-
@actorIndependent lazy var l42: Int = l
609-
@actorIndependent lazy var l43: Int = { self.l }()
610-
@actorIndependent lazy var l44: Int = self.l
611-
@actorIndependent lazy var l45: Int = { [unowned self] in self.l }()
607+
nonisolated lazy var l41: Int = { l }()
608+
nonisolated lazy var l42: Int = l
609+
nonisolated lazy var l43: Int = { self.l }()
610+
nonisolated lazy var l44: Int = self.l
611+
nonisolated lazy var l45: Int = { [unowned self] in self.l }()
612612
}
613613

614614
// Infer global actors from context only for instance members.

test/Concurrency/global_actor_inference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ actor GenericSub<T> : GenericSuper<[T]> {
153153
override func method() { } // expected-note 2{{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
154154

155155
@GenericGlobalActor<T> override func method2() { } // expected-error{{global actor 'GenericGlobalActor<T>'-isolated instance method 'method2()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
156-
@actorIndependent override func method3() { } // expected-error{{actor-independent instance method 'method3()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
156+
nonisolated override func method3() { } // expected-error{{actor-independent instance method 'method3()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
157157

158158
@OtherGlobalActor func testMethod() {
159159
method() // expected-error{{instance method 'method()' isolated to global actor 'GenericGlobalActor<[T]>' can not be referenced from different global actor 'OtherGlobalActor'}}

test/SILGen/hop_to_executor.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ actor MyActor {
99
// CHECK-LABEL: sil hidden [ossa] @$s4test7MyActorC6calleeyySiYF : $@convention(method) @async (Int, @guaranteed MyActor) -> () {
1010
// CHECK-NOT: hop_to_executor
1111
// CHECK: } // end sil function '$s4test7MyActorC6calleeyySiYF'
12-
@actorIndependent
13-
func callee(_ x: Int) async {
12+
nonisolated func callee(_ x: Int) async {
1413
print(x)
1514
}
1615

1716
// CHECK-LABEL: sil hidden [ossa] @$s4test7MyActorC14throwingCalleeyySiYKF : $@convention(method) @async (Int, @guaranteed MyActor) -> @error Error {
1817
// CHECK-NOT: hop_to_executor
1918
// CHECK: } // end sil function '$s4test7MyActorC14throwingCalleeyySiYKF'
20-
@actorIndependent
21-
func throwingCallee(_ x: Int) async throws {
19+
nonisolated func throwingCallee(_ x: Int) async throws {
2220
print(x)
2321
}
2422

test/attr/attr_objc_async.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ actor MyActor {
4444
@objc var badProp: AnyObject { self } // expected-error{{actor-isolated property 'badProp' cannot be @objc}}
4545
@objc subscript(index: Int) -> AnyObject { self } // expected-error{{actor-isolated subscript 'subscript(_:)' cannot be @objc}}
4646

47-
// CHECK: @objc @actorIndependent func synchronousGood()
48-
@objc @actorIndependent func synchronousGood() { }
47+
// CHECK: @objc nonisolated func synchronousGood()
48+
@objc nonisolated func synchronousGood() { }
4949
}
5050

5151
// CHECK: actor class MyActor2

test/attr/global_actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ struct Container {
9696
// Redundant attributes
9797
// -----------------------------------------------------------------------
9898
extension SomeActor {
99-
@GA1 @actorIndependent func conflict1() { } // expected-error{{instance method 'conflict1()' has multiple actor-isolation attributes ('actorIndependent' and 'GA1')}}
99+
@GA1 nonisolated func conflict1() { } // expected-error{{instance method 'conflict1()' has multiple actor-isolation attributes ('nonisolated' and 'GA1')}}
100100
}

test/decl/class/actor/conformance.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ actor OtherActor: SyncProtocol {
4848
@asyncHandler
4949
func syncMethodB() { }
5050

51-
// @actorIndependent methods are okay.
52-
// FIXME: Consider suggesting @actorIndependent if this didn't match.
53-
@actorIndependent func syncMethodC() -> Int { 5 }
51+
// nonisolated methods are okay.
52+
// FIXME: Consider suggesting nonisolated if this didn't match.
53+
nonisolated func syncMethodC() -> Int { 5 }
5454

5555
subscript (index: Int) -> String { "\(index)" }
5656
// expected-error@-1{{actor-isolated subscript 'subscript(_:)' cannot be used to satisfy a protocol requirement}}

test/decl/protocol/special/Actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ actor A6: A1, Actor { // expected-error{{redundant conformance of 'A6' to protoc
2929

3030
actor A7 {
3131
// Okay: satisfy the requirement explicitly
32-
@actorIndependent func enqueue(partialTask: PartialAsyncTask) { }
32+
nonisolated func enqueue(partialTask: PartialAsyncTask) { }
3333
}
3434

3535
// A non-actor can conform to the Actor protocol, if it does it properly.

0 commit comments

Comments
 (0)