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: proposals/0402-extension-macros.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ SE-0389 states that whenever a macro produces declarations that are visible to o
74
74
75
75
The following restrictions apply to generated conformances and names listed in `@attached(extension)`:
76
76
77
-
* An extension macro cannot add a conformance to a protocol that is not covered by the `conformances:` list in `@attached(extension, conformnaces:)`.
77
+
* An extension macro cannot add a conformance to a protocol that is not covered by the `conformances:` list in `@attached(extension, conformances:)`.
78
78
* An extension macro cannot add a member that is not covered by the `names:` list in `@attached(extension, names:)`.
79
79
* An extension macro cannot introduce an extension with an attached `peer` macro, because the peer-macro-generated names are not covered by the original `@attached(extension)` attribute.
80
80
@@ -136,7 +136,7 @@ public protocol ExtensionMacro: AttachedMacro {
136
136
/// to.
137
137
/// - context: The context in which to perform the macro expansion.
138
138
///
139
-
/// - Returns: the set of extensions declarations introduced by the macro,
139
+
/// - Returns: the set of extension declarations introduced by the macro,
140
140
/// which are always inserted at top-level scope. Each extension must extend
141
141
/// the `type` parameter.
142
142
staticfuncexpansion(
@@ -170,7 +170,7 @@ For example, consider the following code which contains an attached extension ma
170
170
protocolEncodable {}
171
171
protocolDecodable {}
172
172
173
-
typelias Codable = Encodable & Decodable
173
+
typealiasCodable= Encodable & Decodable
174
174
175
175
@attached(extension, conformances: Codable)
176
176
macroMyMacro() =#externalMacro(...)
@@ -181,11 +181,11 @@ struct S { ... }
181
181
extensionS: Encodable { ... }
182
182
```
183
183
184
-
The extension macro can add conformances to `Codable`, aka `Encodable & Decodable`. Because the struct `S` already conforms to `Encodable` in the original source, the `ExtensionMacro.expansion` method will recieve the argument `[TypeSyntax(Encodable)]` for the `conformingTo:` parameter. Using this information, the macro implementation can decide to only add an extension with a conformance to `Decodable`.
184
+
The extension macro can add conformances to `Codable`, aka `Encodable & Decodable`. Because the struct `S` already conforms to `Encodable` in the original source, the `ExtensionMacro.expansion` method will receive the argument `[TypeSyntax(Encodable)]` for the `conformingTo:` parameter. Using this information, the macro implementation can decide to only add an extension with a conformance to `Decodable`.
185
185
186
186
## Source compatibility
187
187
188
-
This propsoal removes the `conformance` macro role from SE-0389, which is accepted and implemented in Swift 5.9. If this proposal is accepted after 5.9, the `conformance` macro role will remain in the language as sugar for an `extension` macro that adds only a conformance.
188
+
This proposal removes the `conformance` macro role from SE-0389, which is accepted and implemented in Swift 5.9. If this proposal is accepted after 5.9, the `conformance` macro role will remain in the language as sugar for an `extension` macro that adds only a conformance.
0 commit comments