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
* Type names are no longer allowed as an argument to a subscript parameter that expects a metatype type
151
+
152
+
```swift
153
+
structMyValue {
154
+
}
155
+
156
+
structMyStruct {
157
+
subscript(a: MyValue.Type) ->Int { get { ... } }
158
+
}
159
+
160
+
functest(obj: MyStruct) {
161
+
let_= obj[MyValue]
162
+
}
163
+
```
164
+
165
+
Accepting subscripts with `MyValue` as an argument was an oversight because `MyValue` requires explicit `.self`
166
+
to reference its metatype, so correct syntax would be to use `obj[MyValue.self]`.
167
+
168
+
*[SE-0310][]:
169
+
170
+
Read-only computed properties and subscripts can now define their `get` accessor to be `async` and/or `throws`, by writing one or both of those keywords between the `get` and `{`. Thus, these members can now make asynchronous calls or throw errors in the process of producing a value:
Swift 5.5 includes support for actors, a new kind of type that isolates its instance data to protect it from concurrent access. Accesses to an actor's instance declarations from outside the must be asynchronous:
214
+
215
+
```swift
216
+
actor Counter {
217
+
var value = 0
218
+
219
+
func increment() {
220
+
value = value + 1
221
+
}
222
+
}
223
+
224
+
func useCounter(counter: Counter) async {
225
+
print(await counter.value) // interaction must be async
226
+
await counter.increment() // interaction must be async
227
+
}
228
+
```
229
+
32
230
* The determination of whether a call to a `rethrows` function can throw now considers default arguments of `Optional` type.
33
231
34
232
In Swift 5.4, such default arguments were ignored entirely by `rethrows` checking. This meant that the following example was accepted:
Copy file name to clipboardExpand all lines: docs/Diagnostics.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,7 @@ Clang also has a kind of diagnostic called a "remark", which represents informat
51
51
- "...to silence this warning"
52
52
- "...here" (for a purely locational note)
53
53
54
+
- If possible, it is best to include the name of the type or function that has the error, e.g. "non-actor type 'Nope' cannot ..." is better than "non-actor type cannot ...". It helps developers relate the error message to the specific type the error is about, even if the error would highlight the appropriate line / function in other ways.
0 commit comments