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
The special decls nested inside `@abi` attributes don’t have bodies, so it’s necessary to allow `DeclGroupSyntax.memberBlock` (and the nodes that conform to it, which include the nodes for extensions and nominal types) to be `nil`.
The plan is that `nil`s will *only* occur in new syntax, not elsewhere in Swift code—even if a DeclGroupSyntax node is written without a body, the parser will still create a MemberBlockSyntax for it with missing tokens.
Since `nil` will never occur in pre-existing nodes or code, I’ve chosen to make `memberBlock` an implicitly unwrapped optional. Alternatives would be to make it a normal optional (breaking source compatibility) or to make `memberBlock` a backwards compatibility shim for an optional property with a new name.
I have nevertheless chosen to write all use sites for `memberBlock` as though the property was a normal Optional, except for ones in tests.
Copy file name to clipboardExpand all lines: CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift
+12-6
Original file line number
Diff line number
Diff line change
@@ -227,7 +227,8 @@ public let DECL_NODES: [Node] = [
227
227
),
228
228
Child(
229
229
name:"memberBlock",
230
-
kind:.node(kind:.memberBlock)
230
+
kind:.node(kind:.memberBlock),
231
+
optionality:.implicitlyUnwrapped
231
232
),
232
233
]
233
234
),
@@ -401,7 +402,8 @@ public let DECL_NODES: [Node] = [
401
402
name:"memberBlock",
402
403
kind:.node(kind:.memberBlock),
403
404
documentation:
404
-
"The members of the class declaration. As class extension declarations may declare additional members, the contents of this member block isn't guaranteed to be a complete list of members for this type."
405
+
"The members of the class declaration. As class extension declarations may declare additional members, the contents of this member block isn't guaranteed to be a complete list of members for this type.",
406
+
optionality:.implicitlyUnwrapped
405
407
),
406
408
]
407
409
),
@@ -827,7 +829,8 @@ public let DECL_NODES: [Node] = [
827
829
name:"memberBlock",
828
830
kind:.node(kind:.memberBlock),
829
831
documentation:
830
-
"The cases and other members associated with this enum declaration. Because enum extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
832
+
"The cases and other members associated with this enum declaration. Because enum extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type.",
833
+
optionality:.implicitlyUnwrapped
831
834
),
832
835
]
833
836
),
@@ -906,7 +909,8 @@ public let DECL_NODES: [Node] = [
906
909
name:"memberBlock",
907
910
kind:.node(kind:.memberBlock),
908
911
documentation:
909
-
"The members of the extension declaration. As this is an extension, the contents of this member block isn't guaranteed to be a complete list of members for this type."
912
+
"The members of the extension declaration. As this is an extension, the contents of this member block isn't guaranteed to be a complete list of members for this type.",
913
+
optionality:.implicitlyUnwrapped
910
914
),
911
915
]
912
916
),
@@ -2011,7 +2015,8 @@ public let DECL_NODES: [Node] = [
2011
2015
Child(
2012
2016
name:"memberBlock",
2013
2017
kind:.node(kind:.memberBlock),
2014
-
documentation:"The members of the protocol declaration."
2018
+
documentation:"The members of the protocol declaration.",
2019
+
optionality:.implicitlyUnwrapped
2015
2020
),
2016
2021
]
2017
2022
),
@@ -2182,7 +2187,8 @@ public let DECL_NODES: [Node] = [
2182
2187
name:"memberBlock",
2183
2188
kind:.node(kind:.memberBlock),
2184
2189
documentation:
2185
-
"The members of the struct declaration. Because struct extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
2190
+
"The members of the struct declaration. Because struct extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type.",
0 commit comments