@@ -194,6 +194,26 @@ extension Parser {
194194 mutating func parseSimpleType(
195195 allowMemberTypes: Bool = true ,
196196 forAttributeName: Bool = false
197+ ) -> RawTypeSyntax {
198+ let tilde = self . consumeIfContextualPunctuator ( " ~ " , remapping: . prefixOperator)
199+
200+ let baseType = self . parseUnsuppressedSimpleType (
201+ allowMemberTypes: allowMemberTypes,
202+ forAttributeName: forAttributeName
203+ )
204+
205+ guard let tilde else {
206+ return baseType
207+ }
208+
209+ return RawTypeSyntax (
210+ RawSuppressedTypeSyntax ( withoutTilde: tilde, type: baseType, arena: self . arena)
211+ )
212+ }
213+
214+ mutating func parseUnsuppressedSimpleType(
215+ allowMemberTypes: Bool = true ,
216+ forAttributeName: Bool = false
197217 ) -> RawTypeSyntax {
198218 enum TypeBaseStart : TokenSpecSet {
199219 case `Self`
@@ -227,23 +247,6 @@ extension Parser {
227247 }
228248 }
229249
230- // Eat any '~' preceding the type.
231- let maybeTilde = self . consumeIfContextualPunctuator ( " ~ " , remapping: . prefixOperator)
232-
233- // Wrap as a suppressed type if needed.
234- func wrapInTilde( _ node: RawTypeSyntax ) -> RawTypeSyntax {
235- if let tilde = maybeTilde {
236- return RawTypeSyntax (
237- RawSuppressedTypeSyntax (
238- withoutTilde: tilde,
239- type: node,
240- arena: self . arena
241- )
242- )
243- }
244- return node
245- }
246-
247250 var base : RawTypeSyntax
248251 switch self . at ( anyIn: TypeBaseStart . self) ? . spec {
249252 case . Self, . Any, . identifier:
@@ -255,7 +258,7 @@ extension Parser {
255258 case . wildcard:
256259 base = RawTypeSyntax ( self . parsePlaceholderType ( ) )
257260 case nil :
258- return wrapInTilde ( RawTypeSyntax ( RawMissingTypeSyntax ( arena: self . arena) ) )
261+ return RawTypeSyntax ( RawMissingTypeSyntax ( arena: self . arena) )
259262 }
260263
261264 var loopProgress = LoopProgressCondition ( )
@@ -332,8 +335,6 @@ extension Parser {
332335 break
333336 }
334337
335- base = wrapInTilde ( base)
336-
337338 return base
338339 }
339340
0 commit comments