From f1866d85d03bdf9b7782b1dc783b45aeab1450e8 Mon Sep 17 00:00:00 2001 From: Doug Gregor Date: Tue, 23 Sep 2025 13:16:17 -0700 Subject: [PATCH] Fix indentation for the EmbeddedRestrictions diagnostic group --- userdocs/diagnostics/embedded-restrictions.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/userdocs/diagnostics/embedded-restrictions.md b/userdocs/diagnostics/embedded-restrictions.md index 66f07e553d586..ed10ccea7d00c 100644 --- a/userdocs/diagnostics/embedded-restrictions.md +++ b/userdocs/diagnostics/embedded-restrictions.md @@ -8,50 +8,50 @@ Diagnostics in the `EmbeddedRestrictions` group describe those language features * `weak` and `unowned` references, because Embedded Swift uses a simplified reference-counting model that cannot support them. For example: - class Node { - weak var parent: Node? // error: attribute 'weak' cannot be used in Embedded Swift - } + class Node { + weak var parent: Node? // error: attribute 'weak' cannot be used in Embedded Swift + } * Dynamic casts to a type involving a protocol are not supported, because Embedded Swift does not include runtime metadata about protocol conformances. For example: - protocol P: AnyObject { } - func casting(object: AnyObject) { - if let p = object as? P { // error: cannot perform a dynamic cast to a type involving protocol 'P' in Embedded Swift - // ... + protocol P: AnyObject { } + func casting(object: AnyObject) { + if let p = object as? P { // error: cannot perform a dynamic cast to a type involving protocol 'P' in Embedded Swift + // ... + } } - } * Non-final generic methods in a class, which are prohibited because they cannot be specialized for every possible call site. For example: - class MyGenericClass { - func f(value: U) { } // warning: generic instance method 'f(value:)' in a class must be 'final' in Embedded Swift + class MyGenericClass { + func f(value: U) { } // warning: generic instance method 'f(value:)' in a class must be 'final' in Embedded Swift - func g() { } // okay, not generic relative to the class itself + func g() { } // okay, not generic relative to the class itself - class func h() where T: P { } // warning: generic class method 'h()' in a class must be 'final' in Embedded Swift - } + class func h() where T: P { } // warning: generic class method 'h()' in a class must be 'final' in Embedded Swift + } * Generic methods used on values of protocol type, which are prohibited because they cannot be specialized for every possible call site. For example: - protocol P: AnyObject { - func doNothing() - func doSomething(on value: T) - } + protocol P: AnyObject { + func doNothing() + func doSomething(on value: T) + } - func testGenerics(value: value, i: Int) { - value.doNothing() // okay - value.doSomething(on: i) // okay, always specialized - } + func testGenerics(value: value, i: Int) { + value.doNothing() // okay + value.doSomething(on: i) // okay, always specialized + } - func testValuesOfProtocolType(value: any P, i: Int) { - value.doNothing() // okay - value.doSomething(on: i) // warning: cannot use generic instance method 'doSomething(on:)' on a value of type 'any P' in Embedded Swift - } + func testValuesOfProtocolType(value: any P, i: Int) { + value.doNothing() // okay + value.doSomething(on: i) // warning: cannot use generic instance method 'doSomething(on:)' on a value of type 'any P' in Embedded Swift + } * Use of untyped throws, which depends on `any Error` and is not available in Embedded Swift. Use typed throws instead: - func mayFail() throws { } // error: untyped throws is not available in Embedded Swift; add a thrown error type with '(type)' - func mayFail() throws(MyError) // okay + func mayFail() throws { } // error: untyped throws is not available in Embedded Swift; add a thrown error type with '(type)' + func mayFail() throws(MyError) // okay ## See Also