Skip to content

Commit 9b8d00a

Browse files
authored
Merge pull request #59626 from tshortli/release-note-ban-available-on-all-stored-properties-main
NFC: Add a CHANGELOG entry about banning @available on lazy and wrapped properties
2 parents 5b6ec5d + 3d689d8 commit 9b8d00a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
488488
the result type provides a generalization where the callee chooses the
489489
resulting type and value.
490490

491+
* The compiler now correctly emits errors for `@available` attributes on stored properties with the `lazy` modifier or with attached property wrappers. Previously, the attribute was accepted on this subset of stored properties but the resulting binary would crash at runtime when type metadata was unavailable.
492+
493+
```swift
494+
struct S {
495+
@available(macOS 99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
496+
lazy var a: Int = 42
497+
498+
@available(macOS 99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
499+
@Wrapper var b: Int
500+
}
501+
```
502+
491503
* The compiler now correctly emits warnings for more kinds of expressions where a protocol conformance is used and may be unavailable at runtime. Previously, member reference expressions and type erasing expressions that used potentially unavailable conformances were not diagnosed, leading to potential crashes at runtime.
492504

493505
```swift

0 commit comments

Comments
 (0)