Skip to content

Commit 4e93e74

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. Resolves: rdar://155589753 (cherry picked from commit a9373c0)
1 parent a349e64 commit 4e93e74

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
@@ -4346,7 +4346,6 @@ static void checkGlobalActorAttr(
43464346
attributes[1])
43474347
.highlight(attributes[0]->getRangeWithAt())
43484348
.highlight(attributes[1]->getRangeWithAt())
4349-
.warnUntilSwiftVersion(6)
43504349
.fixItRemove(attributes[1]->getRangeWithAt());
43514350
return;
43524351
}
@@ -4357,7 +4356,6 @@ static void checkGlobalActorAttr(
43574356
.highlight(attributes[0]->getRangeWithAt())
43584357
.highlight(attributes[1]->getRangeWithAt())
43594358
.highlight(attributes[2]->getRangeWithAt())
4360-
.warnUntilSwiftVersion(6)
43614359
.fixItRemove(attributes[1]->getRangeWithAt())
43624360
.fixItRemove(attributes[2]->getRangeWithAt());
43634361
return;
@@ -4370,7 +4368,6 @@ static void checkGlobalActorAttr(
43704368
.highlight(attributes[1]->getRangeWithAt())
43714369
.highlight(attributes[2]->getRangeWithAt())
43724370
.highlight(attributes[3]->getRangeWithAt())
4373-
.warnUntilSwiftVersion(6)
43744371
.fixItRemove(attributes[1]->getRangeWithAt())
43754372
.fixItRemove(attributes[2]->getRangeWithAt())
43764373
.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)