Skip to content

Commit 2a3bfe9

Browse files
authored
Merge pull request #59625 from tshortli/release-note-ban-available-on-all-stored-properties
NFC: Add a CHANGELOG entry about banning `@available` on lazy and wrapped properties in 5.7
2 parents 5418c4e + d09b481 commit 2a3bfe9

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
@@ -401,6 +401,18 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
401401
the result type provides a generalization where the callee chooses the
402402
resulting type and value.
403403

404+
* 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.
405+
406+
```swift
407+
struct S {
408+
@available(macOS 99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
409+
lazy var a: Int = 42
410+
411+
@available(macOS 99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
412+
@Wrapper var b: Int
413+
}
414+
```
415+
404416
* 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.
405417

406418
```swift

0 commit comments

Comments
 (0)