Skip to content

Commit df8a4c8

Browse files
authored
Merge pull request #78468 from slavapestov/fix-141967932
Sema: Don't remove nonisolated attribute when we diagnose it as invalid on 'lazy'
2 parents 8397fc3 + e663ad0 commit df8a4c8

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7459,7 +7459,7 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
74597459
}
74607460

74617461
if (var->getAttrs().hasAttribute<LazyAttr>()) {
7462-
diagnoseAndRemoveAttr(attr, diag::nonisolated_lazy)
7462+
diagnose(attr->getLocation(), diag::nonisolated_lazy)
74637463
.warnUntilSwiftVersion(6);
74647464
return;
74657465
}

test/Concurrency/actor_isolation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,13 @@ actor LazyActor {
838838
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
839839
nonisolated lazy var l32: Int = v
840840
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
841+
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
841842
nonisolated lazy var l33: Int = { self.v }()
842843
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
843844
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
844845
nonisolated lazy var l34: Int = self.v
845846
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
847+
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}
846848
nonisolated lazy var l35: Int = { [unowned self] in self.v }()
847849
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
848850
// expected-warning@-2 {{actor-isolated default value in a nonisolated context; this is an error in the Swift 6 language mode}}

test/Concurrency/actor_isolation_objc.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ actor Dril: NSObject {
6464

6565
// makes sure the synthesized init's delegation kind is determined correctly.
6666
actor Pumpkin: NSObject {}
67+
68+
actor Bad {
69+
@objc nonisolated lazy var invalid = 0
70+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
71+
}

0 commit comments

Comments
 (0)