Skip to content

Commit bb066b6

Browse files
committed
[Concurrency] Make actor-isolated protocol witnesses an error.
With actor isolation checking for protocol witnesses moved out of the witness-matching phase, move the corresponding diagnostics from notes (that would have been on the "type does not conform" error) to freestanding errors.
1 parent 591e6e8 commit bb066b6

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4172,10 +4172,10 @@ NOTE(actor_mutable_state,none,
41724172
WARNING(shared_mutable_state_access,none,
41734173
"reference to %0 %1 is not concurrency-safe because it involves "
41744174
"shared mutable state", (DescriptiveDeclKind, DeclName))
4175-
NOTE(actor_isolated_witness,none,
4175+
ERROR(actor_isolated_witness,none,
41764176
"actor-isolated %0 %1 cannot be used to satisfy a protocol requirement",
41774177
(DescriptiveDeclKind, DeclName))
4178-
NOTE(actor_isolated_witness_could_be_async_handler,none,
4178+
ERROR(actor_isolated_witness_could_be_async_handler,none,
41794179
"actor-isolated %0 %1 cannot be used to satisfy a protocol requirement; "
41804180
"did you mean to make it an asychronous handler?",
41814181
(DescriptiveDeclKind, DeclName))

test/decl/class/actor/conformance.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,32 @@ extension MyActor: AsyncProtocol {
1212
func asyncMethod() async -> Int { return 0 }
1313
}
1414

15-
// FIXME: "Do you want to add a stub?" diagnostics should be suppressed here.
1615
protocol SyncProtocol {
1716
var propertyA: Int { get }
18-
// expected-note@-1{{do you want to add a stub}}
1917
var propertyB: Int { get set }
20-
// expected-note@-1{{do you want to add a stub}}
2118

2219
func syncMethodA()
23-
// expected-note@-1{{do you want to add a stub}}
2420

2521
func syncMethodB()
2622

2723
func syncMethodC() -> Int
2824

2925
subscript (index: Int) -> String { get }
30-
// expected-note@-1{{do you want to add a stub}}
3126

3227
static func staticMethod()
3328
static var staticProperty: Int { get }
3429
}
3530

3631

37-
actor class OtherActor: SyncProtocol { // expected-error{{type 'OtherActor' does not conform to protocol 'SyncProtocol'}}
32+
actor class OtherActor: SyncProtocol {
3833
var propertyB: Int = 17
39-
// expected-note@-1{{actor-isolated property 'propertyB' cannot be used to satisfy a protocol requirement}}
34+
// expected-error@-1{{actor-isolated property 'propertyB' cannot be used to satisfy a protocol requirement}}
4035

4136
var propertyA: Int { 17 }
42-
// expected-note@-1{{actor-isolated property 'propertyA' cannot be used to satisfy a protocol requirement}}
37+
// expected-error@-1{{actor-isolated property 'propertyA' cannot be used to satisfy a protocol requirement}}
4338

4439
func syncMethodA() { }
45-
// expected-note@-1{{actor-isolated instance method 'syncMethodA()' cannot be used to satisfy a protocol requirement; did you mean to make it an asychronous handler?}}{{3-3=@asyncHandler }}
40+
// expected-error@-1{{actor-isolated instance method 'syncMethodA()' cannot be used to satisfy a protocol requirement; did you mean to make it an asychronous handler?}}{{3-3=@asyncHandler }}
4641

4742
// Async handlers are okay.
4843
@asyncHandler
@@ -53,7 +48,7 @@ actor class OtherActor: SyncProtocol { // expected-error{{type 'OtherActor' does
5348
@actorIndependent func syncMethodC() -> Int { 5 }
5449

5550
subscript (index: Int) -> String { "\(index)" }
56-
// expected-note@-1{{actor-isolated subscript 'subscript(_:)' cannot be used to satisfy a protocol requirement}}
51+
// expected-error@-1{{actor-isolated subscript 'subscript(_:)' cannot be used to satisfy a protocol requirement}}
5752

5853
// Static methods and properties are okay.
5954
static func staticMethod() { }

test/decl/protocol/special/Actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class C1: Actor {
4242

4343
// Method that is not usable as a witness.
4444
actor class BA1 {
45-
func enqueue(partialTask: PartialAsyncTask) { } // expected-note{{actor-isolated instance method 'enqueue(partialTask:)' cannot be used to satisfy a protocol requirement; did you mean to make it an asychronous handler?}}
45+
func enqueue(partialTask: PartialAsyncTask) { } // expected-error{{actor-isolated instance method 'enqueue(partialTask:)' cannot be used to satisfy a protocol requirement; did you mean to make it an asychronous handler?}}
4646
}
4747

4848
// Method that isn't part of the main class definition cannot be used to

0 commit comments

Comments
 (0)