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
Embedded Swift doesn't have protocol conformance metadata, so it cannot
handle dynamic casts to existentials (nor should it).
Another part of rdar://119383905.
Copy file name to clipboardExpand all lines: userdocs/diagnostics/embedded-restrictions.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,15 @@ Diagnostics in the `EmbeddedRestrictions` group describe those language features
12
12
weak var parent: Node? // error: attribute 'weak' cannot be used in Embedded Swift
13
13
}
14
14
15
+
* Dynamic casts to a type involving a protocol are not supported, because Embedded Swift does not include runtime metadata about protocol conformances. For example:
16
+
17
+
protocol P: AnyObject { }
18
+
func casting(object: AnyObject) {
19
+
if let p = object as? P { // error: cannot perform a dynamic cast to a type involving protocol 'P' in Embedded Swift
20
+
// ...
21
+
}
22
+
}
23
+
15
24
* Non-final generic methods in a class, which are prohibited because they cannot be specialized for every possible call site. For example:
0 commit comments