@@ -225,33 +225,27 @@ extension CaptureStructure: CustomStringConvertible {
225225extension AST {
226226 /// The capture structure of this AST for compiler communication.
227227 var captureStructure : CaptureStructure {
228- captureList. _captureStructure ( nestOptionals : true )
228+ captureList. _captureStructure
229229 }
230230}
231231
232232// MARK: Convert CaptureList into CaptureStructure
233233
234234extension CaptureList {
235- func _captureStructure( nestOptionals : Bool ) -> CaptureStructure {
235+ var _captureStructure : CaptureStructure {
236236 if captures. isEmpty { return . empty }
237237 if captures. count == 1 {
238- return captures. first!. _captureStructure ( nestOptionals : nestOptionals )
238+ return captures. first!. _captureStructure
239239 }
240- return . tuple( captures. map {
241- $0. _captureStructure ( nestOptionals: nestOptionals)
242- } )
240+ return . tuple( captures. map ( \. _captureStructure) )
243241 }
244242}
245243
246244extension CaptureList . Capture {
247- func _captureStructure( nestOptionals: Bool ) -> CaptureStructure {
248- if optionalDepth == 0 {
249- return . atom( name: name, type: type == Substring . self ? nil : . init( type) )
250- }
251- var copy = self
252- copy. optionalDepth = 0
253- var base = copy. _captureStructure ( nestOptionals: false )
254- for _ in 0 ..< ( nestOptionals ? optionalDepth : 1 ) {
245+ var _captureStructure : CaptureStructure {
246+ var base = CaptureStructure . atom (
247+ name: name, type: type == Substring . self ? nil : . init( type) )
248+ for _ in 0 ..< optionalDepth {
255249 base = . optional( base)
256250 }
257251 return base
0 commit comments