Skip to content

Commit 3d689d8

Browse files
committed
NFC: Add an entry about banning @available on lazy and wrapped properties.
These more accurate diagnostics resulted in source breaks for some projects but the now rejected code would crash when back deployed so it was important to diagnose correctly.
1 parent 5b6ec5d commit 3d689d8

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)