Skip to content

Commit ec387fa

Browse files
committed
Sema: Don't remove nonisolated attribute when we diagnose it as invalid on 'lazy'
Otherwise, we'll in turn complain if the nonisolated lazy property was @objc. This is also invalid, but the goal here is to avoid the source break until -swift-version 6. Fixes rdar://141967932.
1 parent 5bcb696 commit ec387fa

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

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

74517451
if (var->getAttrs().hasAttribute<LazyAttr>()) {
7452-
diagnoseAndRemoveAttr(attr, diag::nonisolated_lazy)
7452+
diagnose(attr->getLocation(), diag::nonisolated_lazy)
74537453
.warnUntilSwiftVersion(6);
74547454
return;
74557455
}

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)