@@ -100,6 +100,7 @@ extension Parser {
100100 RawAttributedTypeSyntax (
101101 specifiers: specifiersAndAttributes. specifiers,
102102 attributes: specifiersAndAttributes. attributes,
103+ lateSpecifiers: specifiersAndAttributes. lateSpecifiers,
103104 baseType: base,
104105 arena: self . arena
105106 )
@@ -1221,7 +1222,8 @@ extension Parser {
12211222 misplacedSpecifiers: [ RawTokenSyntax ] = [ ]
12221223 ) -> (
12231224 specifiers: RawTypeSpecifierListSyntax ,
1224- attributes: RawAttributeListSyntax
1225+ attributes: RawAttributeListSyntax ,
1226+ lateSpecifiers: RawTypeSpecifierListSyntax
12251227 ) ? {
12261228 var specifiers : [ RawTypeSpecifierListSyntax . Element ] = [ ]
12271229 SPECIFIER_PARSING: while canHaveParameterSpecifier {
@@ -1260,7 +1262,15 @@ extension Parser {
12601262 attributes = nil
12611263 }
12621264
1263- guard !specifiers. isEmpty || attributes != nil else {
1265+ // Only handle `nonisolated` as a late specifier.
1266+ var lateSpecifiers : [ RawTypeSpecifierListSyntax . Element ] = [ ]
1267+ if self . at ( . keyword( . nonisolated) ) && !( self . peek ( isAt: . leftParen) && self . peek ( ) . isAtStartOfLine)
1268+ && canHaveParameterSpecifier
1269+ {
1270+ lateSpecifiers. append ( parseNonisolatedTypeSpecifier ( ) )
1271+ }
1272+
1273+ guard !specifiers. isEmpty || attributes != nil || !lateSpecifiers. isEmpty else {
12641274 // No specifiers or attributes on this type
12651275 return nil
12661276 }
@@ -1271,9 +1281,17 @@ extension Parser {
12711281 specifierList = RawTypeSpecifierListSyntax ( elements: specifiers, arena: arena)
12721282 }
12731283
1284+ let lateSpecifierList : RawTypeSpecifierListSyntax
1285+ if lateSpecifiers. isEmpty {
1286+ lateSpecifierList = self . emptyCollection ( RawTypeSpecifierListSyntax . self)
1287+ } else {
1288+ lateSpecifierList = RawTypeSpecifierListSyntax ( elements: lateSpecifiers, arena: arena)
1289+ }
1290+
12741291 return (
12751292 specifierList,
1276- attributes ?? self . emptyCollection ( RawAttributeListSyntax . self)
1293+ attributes ?? self . emptyCollection ( RawAttributeListSyntax . self) ,
1294+ lateSpecifierList
12771295 )
12781296 }
12791297
0 commit comments