Skip to content

Commit b579a9e

Browse files
authored
Merge pull request #78469 from slavapestov/fix-141967932-6.1
[6.1] Fix source break with invalid `nonisolated lazy` properties
2 parents 7b4a1ab + 27febe2 commit b579a9e

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7281,8 +7281,8 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
72817281
}
72827282

72837283
if (var->getAttrs().hasAttribute<LazyAttr>()) {
7284-
diagnoseAndRemoveAttr(attr, diag::nonisolated_lazy)
7285-
.warnUntilSwiftVersionIf(attr->isImplicit(), 6);
7284+
diagnose(attr->getLocation(), diag::nonisolated_lazy)
7285+
.warnUntilSwiftVersion(6);
72867286
return;
72877287
}
72887288

test/Concurrency/actor_isolation.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -834,29 +834,31 @@ actor LazyActor {
834834
lazy var l25: Int = { [unowned self] in self.l }()
835835

836836
nonisolated lazy var l31: Int = { v }()
837-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
837+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
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
840-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
840+
// 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 }()
842-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
843+
// 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
845-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
846+
// 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 }()
847-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
849+
// 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}}
849851

850852
nonisolated lazy var l41: Int = { l }()
851-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
853+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
852854
nonisolated lazy var l42: Int = l
853-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
855+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
854856
nonisolated lazy var l43: Int = { self.l }()
855-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
857+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
856858
nonisolated lazy var l44: Int = self.l
857-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
859+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
858860
nonisolated lazy var l45: Int = { [unowned self] in self.l }()
859-
// expected-error@-1 {{'nonisolated' is not supported on lazy properties}}
861+
// expected-warning@-1 {{'nonisolated' is not supported on lazy properties; this is an error in the Swift 6 language mode}}
860862
}
861863

862864
// Infer global actors from context only for instance members.

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)