You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+29-6Lines changed: 29 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,22 +90,33 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
90
90
}
91
91
```
92
92
93
-
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on the `AnyObject`metatype are now supported. These references always have the type of a function that accepts a single argument and returns an optional value of function type:
93
+
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on `AnyObject` are now supported on par with other function references. The type of such a reference (formerly an immediate optional by mistake) has been altered to that of a function that takes a single argument and returns an optional value of function type:
94
94
95
95
```swift
96
96
classObject {
97
-
@objcfuncgetTag() ->Int
97
+
@objcfuncgetTag() ->Int { ... }
98
98
}
99
99
100
-
@objcprotocolP {
100
+
let getTag: (AnyObject) -> (() ->Int)?=AnyObject.getTag
101
+
102
+
@objcprotocolDelegate {
101
103
@objcoptionalfuncdidUpdateObject(withTagtag: Int)
102
104
}
103
105
104
-
let getTag: (AnyObject) -> (() ->Int)?=AnyObject.getTag
105
-
106
-
let didUpdateObject: (any P) -> ((Int) ->Void)?= P.didUpdateObject
106
+
let didUpdateObjectWithTag: (Delegate) -> ((Int) ->Void)?= Delegate.didUpdateObject
107
107
```
108
108
109
+
> **Warning**
110
+
> Due to the type change, selectors for aforementioned method references that require writing out their type explicitly for disambiguation will no longer compile. To fix this, simply adjust the written type, or resort to a `#if swift(<5.7)` directive when compatibility with older compiler versions is warranted. For example:
Loading data from raw memory represented by `UnsafeRawPointer`,
@@ -390,6 +401,18 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
390
401
the result type provides a generalization where the callee chooses the
391
402
resulting type and value.
392
403
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
+
structS {
408
+
@available(macOS99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
409
+
lazyvar a: Int=42
410
+
411
+
@available(macOS99, *) // error: stored properties cannot be marked potentially unavailable with '@available'
412
+
@Wrappervar b: Int
413
+
}
414
+
```
415
+
393
416
* 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.
0 commit comments