Skip to content

Sema: Don't remove nonisolated attribute when we diagnose it as invalid on 'lazy' #78468

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
Jan 8, 2025
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
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7449,7 +7449,7 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
}

if (var->getAttrs().hasAttribute<LazyAttr>()) {
diagnoseAndRemoveAttr(attr, diag::nonisolated_lazy)
diagnose(attr->getLocation(), diag::nonisolated_lazy)
.warnUntilSwiftVersion(6);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions test/Concurrency/actor_isolation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,13 @@ actor LazyActor {
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
nonisolated lazy var l32: Int = v
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
nonisolated lazy var l33: Int = { self.v }()
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
nonisolated lazy var l34: Int = self.v
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
nonisolated lazy var l35: Int = { [unowned self] in self.v }()
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
Expand Down
5 changes: 5 additions & 0 deletions test/Concurrency/actor_isolation_objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ actor Dril: NSObject {

// makes sure the synthesized init's delegation kind is determined correctly.
actor Pumpkin: NSObject {}

actor Bad {
@objc nonisolated lazy var invalid = 0
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
}