Skip to content

Commit 6743b61

Browse files
nkcsgexirintaro
authored andcommitted
IDE: treat some as keyword for opaque result type
1 parent 644b5ec commit 6743b61

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/Parse/ParseType.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
683683
if (Context.LangOpts.EnableOpaqueResultTypes
684684
&& Tok.is(tok::identifier)
685685
&& Tok.getRawText() == "some") {
686+
// Treat some as a keyword.
687+
TokReceiver->registerTokenKindChange(Tok.getLoc(), tok::contextual_keyword);
686688
opaqueLoc = consumeToken();
687689
} else {
688690
// This isn't a some type.

test/IDE/coloring.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,9 @@ let closure = { [weak x=bindtox, unowned y=bindtoy, unowned(unsafe) z=bindtoz] i
417417
protocol FakeClassRestrictedProtocol : `class` {}
418418
// CHECK: <kw>protocol</kw> FakeClassRestrictedProtocol : <type>`class`</type> {}
419419
// FIXME: rdar://42801404: OLD and NEW should be the same '<type>`class`</type>'.
420+
421+
// CHECK: <kw>func</kw> foo() -> <kw>some</kw> <type>P</type> {}
422+
func foo() -> some P {}
423+
424+
// CHECK: <kw>func</kw> foo() -> <kw>some</kw> <type>P</type> & <type>Q</type> {}
425+
func foo() -> some P & Q {}

utils/gyb_syntax_support/TypeNodes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
Node('SomeType', kind='Type',
8282
children=[
8383
Child('SomeSpecifier', kind='IdentifierToken',
84+
classification='Keyword',
8485
text_choices=['some']),
8586
Child('BaseType', kind='Type'),
8687
]),

0 commit comments

Comments
 (0)