Skip to content

[Concurrency] Downgrade invalid global actors on accessors to a warning until Swift 6. #69853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ GlobalActorAttributeRequest::evaluate(
if (!accessor->isGetter()) {
decl->diagnose(diag::global_actor_disallowed,
decl->getDescriptiveKind())
.warnUntilSwiftVersion(6)
.fixItRemove(globalActorAttr->getRangeWithAt());

auto *storage = accessor->getStorage();
Expand Down
18 changes: 9 additions & 9 deletions test/attr/global_actor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ do {
var test1: Int {
get { 42 }
@GA1
set { } // expected-error {{setter cannot have a global actor}} {{158:7-11=}}
set { } // expected-warning {{setter cannot have a global actor}} {{158:7-11=}}
// expected-note@-1 {{move global actor attribute to property 'test1'}} {{156:5-5=@GA1}}

@GA1 _modify { fatalError() } // expected-error {{_modify accessor cannot have a global actor}} {{7-12=}}
@GA1 _modify { fatalError() } // expected-warning {{_modify accessor cannot have a global actor}} {{7-12=}}
// expected-note@-1 {{move global actor attribute to property 'test1'}} {{156:5-5=@GA1}}
}

Expand All @@ -168,41 +168,41 @@ do {
get { false }

@GA1
set { } // expected-error {{setter cannot have a global actor}}
set { } // expected-warning {{setter cannot have a global actor}}
}
}

@GA1 var testAlreadyWithGlobal: String {
get { "" }
@GA1 set { } // expected-error {{setter cannot have a global actor}} {{7-12=}}
@GA1 set { } // expected-warning {{setter cannot have a global actor}} {{7-12=}}
}
}

struct TestStruct {
var test1: Int {
get { 42 }
@GA1
set { } // expected-error {{setter cannot have a global actor}} {{184:7-11=}}
set { } // expected-warning {{setter cannot have a global actor}} {{184:7-11=}}
// expected-note@-1 {{move global actor attribute to property 'test1'}} {{182:5-5=@GA1}}
@GA1 _modify { fatalError() } // expected-error {{_modify accessor cannot have a global actor}} {{7-12=}}
@GA1 _modify { fatalError() } // expected-warning {{_modify accessor cannot have a global actor}} {{7-12=}}
// expected-note@-1 {{move global actor attribute to property 'test1'}} {{182:5-5=@GA1}}
}

var test2: Int {
@GA1 willSet { // expected-error {{willSet observer cannot have a global actor}} {{7-12=}}
@GA1 willSet { // expected-warning {{willSet observer cannot have a global actor}} {{7-12=}}
// expected-note@-1 {{move global actor attribute to property 'test2'}} {{191:5-5=@GA1}}
}
}

subscript(x: Int) -> Bool {
get { true }
@GA1 set { } // expected-error {{setter cannot have a global actor}} {{7-12=}}
@GA1 set { } // expected-warning {{setter cannot have a global actor}} {{7-12=}}
// expected-note@-1 {{move global actor attribute to subscript 'subscript(_:)'}} {{197:5-5=@GA1}}
}

@GA1 subscript(y: Bool) -> String {
get { "" }
@GA1 set { } // expected-error {{setter cannot have a global actor}} {{7-12=}}
@GA1 set { } // expected-warning {{setter cannot have a global actor}} {{7-12=}}
}
}
}