Skip to content

Commit a912af5

Browse files
committed
[Parse] Set missing contextual keyword token kind for async
Resolves rdar://93080331.
1 parent 78f937f commit a912af5

File tree

6 files changed

+46
-4
lines changed

6 files changed

+46
-4
lines changed

lib/Parse/ParsePattern.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ ParserStatus Parser::parseEffectsSpecifiers(SourceLoc existingArrowLoc,
978978
.fixItInsert(throwsLoc, isReasync ? "reasync " : "async ");
979979
}
980980
if (asyncLoc.isInvalid()) {
981+
Tok.setKind(tok::contextual_keyword);
981982
if (reasync)
982983
*reasync = isReasync;
983984
asyncLoc = Tok.getLoc();

test/IDE/coloring.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ protocol Prot {
174174
var protocolProperty1: Int { get }
175175
// CHECK: <kw>var</kw> protocolProperty2: <type>Int</type> { <kw>get</kw> <kw>set</kw> }
176176
var protocolProperty2: Int { get set }
177+
// CHECK: <kw>var</kw> protoAsyncProp: <type>Int</type> { <kw>get</kw> <kw>async</kw> }
178+
var protoAsyncProp: Int { get async }
177179
}
178180

179181
// CHECK: <attr-builtin>infix</attr-builtin> <kw>operator</kw> *-* : FunnyPrecedence{{$}}

test/SourceKit/SyntaxMapData/Inputs/syntaxmap.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ enum A {
6464
case namedArguments(param1: String, param2: Int)
6565
case mutedArguments(String, Int)
6666
}
67+
68+
protocol AsyncPropTest {
69+
var protoAsyncProp: Int { get async }
70+
}

test/SourceKit/SyntaxMapData/syntaxmap.swift.response

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
key.offset: 0,
3-
key.length: 1325,
3+
key.length: 1393,
44
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
55
key.syntaxmap: [
66
{
@@ -707,6 +707,41 @@
707707
key.kind: source.lang.swift.syntaxtype.typeidentifier,
708708
key.offset: 1318,
709709
key.length: 3
710+
},
711+
{
712+
key.kind: source.lang.swift.syntaxtype.keyword,
713+
key.offset: 1326,
714+
key.length: 8
715+
},
716+
{
717+
key.kind: source.lang.swift.syntaxtype.identifier,
718+
key.offset: 1335,
719+
key.length: 13
720+
},
721+
{
722+
key.kind: source.lang.swift.syntaxtype.keyword,
723+
key.offset: 1353,
724+
key.length: 3
725+
},
726+
{
727+
key.kind: source.lang.swift.syntaxtype.identifier,
728+
key.offset: 1357,
729+
key.length: 14
730+
},
731+
{
732+
key.kind: source.lang.swift.syntaxtype.typeidentifier,
733+
key.offset: 1373,
734+
key.length: 3
735+
},
736+
{
737+
key.kind: source.lang.swift.syntaxtype.keyword,
738+
key.offset: 1379,
739+
key.length: 3
740+
},
741+
{
742+
key.kind: source.lang.swift.syntaxtype.keyword,
743+
key.offset: 1383,
744+
key.length: 5
710745
}
711746
]
712747
}

utils/gyb_syntax_support/DeclNodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
Node('FunctionSignature', kind='Syntax',
7777
children=[
7878
Child('Input', kind='ParameterClause'),
79-
Child('AsyncOrReasyncKeyword', kind='IdentifierToken',
79+
Child('AsyncOrReasyncKeyword', kind='ContextualKeywordToken',
8080
classification='Keyword',
8181
text_choices=['async', 'reasync'], is_optional=True),
8282
Child('ThrowsOrRethrowsKeyword', kind='Token',
@@ -538,7 +538,7 @@
538538
'_read', '_modify'
539539
]),
540540
Child('Parameter', kind='AccessorParameter', is_optional=True),
541-
Child('AsyncKeyword', kind='IdentifierToken',
541+
Child('AsyncKeyword', kind='ContextualKeywordToken',
542542
classification='Keyword',
543543
text_choices=['async'], is_optional=True),
544544
Child('ThrowsKeyword', kind='Token',

utils/gyb_syntax_support/TypeNodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
Child('Arguments', kind='TupleTypeElementList',
168168
collection_element_name='Argument'),
169169
Child('RightParen', kind='RightParenToken'),
170-
Child('AsyncKeyword', kind='IdentifierToken',
170+
Child('AsyncKeyword', kind='ContextualKeyworkToken',
171171
classification='Keyword',
172172
text_choices=['async'], is_optional=True),
173173
Child('ThrowsOrRethrowsKeyword', kind='Token',

0 commit comments

Comments
 (0)