Skip to content

Commit a9373c0

Browse files
committed
[Concurrency] Don't downgrade explicit isolation attribute clashes
The compiler shouldn't accept mismatch in explicit isolation attributes because it could lead to incorrect isolation selection.
1 parent 65d9f5f commit a9373c0

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4405,7 +4405,6 @@ static void checkGlobalActorAttr(
44054405
attributes[1])
44064406
.highlight(attributes[0]->getRangeWithAt())
44074407
.highlight(attributes[1]->getRangeWithAt())
4408-
.warnUntilSwiftVersion(6)
44094408
.fixItRemove(attributes[1]->getRangeWithAt());
44104409
return;
44114410
}
@@ -4416,7 +4415,6 @@ static void checkGlobalActorAttr(
44164415
.highlight(attributes[0]->getRangeWithAt())
44174416
.highlight(attributes[1]->getRangeWithAt())
44184417
.highlight(attributes[2]->getRangeWithAt())
4419-
.warnUntilSwiftVersion(6)
44204418
.fixItRemove(attributes[1]->getRangeWithAt())
44214419
.fixItRemove(attributes[2]->getRangeWithAt());
44224420
return;
@@ -4429,7 +4427,6 @@ static void checkGlobalActorAttr(
44294427
.highlight(attributes[1]->getRangeWithAt())
44304428
.highlight(attributes[2]->getRangeWithAt())
44314429
.highlight(attributes[3]->getRangeWithAt())
4432-
.warnUntilSwiftVersion(6)
44334430
.fixItRemove(attributes[1]->getRangeWithAt())
44344431
.fixItRemove(attributes[2]->getRangeWithAt())
44354432
.fixItRemove(attributes[3]->getRangeWithAt());

test/Concurrency/isolated_parameters.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ func isolatedClosures() {
339339
}
340340
}
341341

342-
// expected-warning@+3 {{global function 'allOfEm' has multiple actor-isolation attributes (@MainActor and 'nonisolated')}}
343-
// expected-warning@+2 {{global function with 'isolated' parameter cannot be 'nonisolated'; this is an error in the Swift 6 language mode}}{{12-24=}}
344-
// expected-warning@+1 {{global function with 'isolated' parameter cannot have a global actor; this is an error in the Swift 6 language mode}}{{1-12=}}
342+
#if ALLOW_TYPECHECKER_ERRORS
343+
344+
// expected-typechecker-error@+3 {{global function 'allOfEm' has multiple actor-isolation attributes (@MainActor and 'nonisolated')}}
345+
// expected-typechecker-warning@+2 {{global function with 'isolated' parameter cannot be 'nonisolated'; this is an error in the Swift 6 language mode}}{{12-24=}}
346+
// expected-typechecker-warning@+1 {{global function with 'isolated' parameter cannot have a global actor; this is an error in the Swift 6 language mode}}{{1-12=}}
345347
@MainActor nonisolated func allOfEm(_ a: isolated A) {
346348
a.f()
347349
}
348350

349-
#if ALLOW_TYPECHECKER_ERRORS
350-
351351
@MainActor class MAClass {
352352

353353
// expected-typechecker-note@+2 {{previous 'isolated' parameter 'a'}}

test/attr/execution_behavior_attrs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ struct TestAttributeCollisions {
9999
}
100100

101101
@MainActor @concurrent func testGlobalActor() async {}
102-
// expected-warning @-1 {{instance method 'testGlobalActor()' has multiple actor-isolation attributes (@MainActor and @concurrent)}}
102+
// expected-error@-1 {{instance method 'testGlobalActor()' has multiple actor-isolation attributes (@MainActor and @concurrent)}}
103103

104104
nonisolated(nonsending) nonisolated func testNonIsolatedCaller() async {} // expected-error {{duplicate modifier}} expected-note {{modifier already specified here}}
105105
@MainActor nonisolated(nonsending) func testGlobalActorCaller() async {}
106-
// expected-warning@-1 {{instance method 'testGlobalActorCaller()' has multiple actor-isolation attributes (@MainActor and 'nonisolated(nonsending)')}}
106+
// expected-error@-1 {{instance method 'testGlobalActorCaller()' has multiple actor-isolation attributes (@MainActor and 'nonisolated(nonsending)')}}
107107
nonisolated(nonsending) func testCaller(arg: isolated MainActor) async {}
108108
// expected-error@-1 {{cannot use 'nonisolated(nonsending)' on instance method 'testCaller(arg:)' because it has an isolated parameter: 'arg'}}
109109

test/attr/global_actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct Container {
9898
// Redundant attributes
9999
// -----------------------------------------------------------------------
100100
extension SomeActor {
101-
@GA1 nonisolated func conflict1() { } // expected-warning {{instance method 'conflict1()' has multiple actor-isolation attributes (@GA1 and 'nonisolated')}}
101+
@GA1 nonisolated func conflict1() { } // expected-error {{instance method 'conflict1()' has multiple actor-isolation attributes (@GA1 and 'nonisolated')}}
102102
}
103103

104104

0 commit comments

Comments
 (0)