Skip to content

Commit 7f082e1

Browse files
committed
[Parser] Ignore generic arguments after a code completion token
1 parent 56ea334 commit 7f082e1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,11 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
17601760
}
17611761
}
17621762
consumeToken(tok::code_complete);
1763+
if (canParseAsGenericArgumentList()) {
1764+
SmallVector<TypeRepr*, 8> args;
1765+
SourceLoc LAngleLoc, RAngleLoc;
1766+
parseGenericArguments(args, LAngleLoc, RAngleLoc);
1767+
}
17631768
return Result;
17641769
}
17651770

test/IDE/complete_constructor.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,19 @@ func testInitWithUnresolved() {
361361
// INIT_WITH_UNRESOLVEDTYPE_1-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#arg2: _#}[')'][#InitWithUnresolved<_>#];
362362
// INIT_WITH_UNRESOLVEDTYPE_1: End completions
363363
}
364+
365+
func testIgnoreGenericArgsAfterCompletionToken() {
366+
struct IPv4 {}
367+
368+
public struct HostRecord<IPType> {
369+
init(position: inout Int) throws {}
370+
}
371+
372+
func deserializeRecord() throws -> HostRecord<IPv4> {
373+
var position = 42
374+
return try #^IGNORE_GENERIC_ARGS_AFTER_COMPLETION_TOKEN^#HostRecord<IPv4>(position: &position)
375+
// IGNORE_GENERIC_ARGS_AFTER_COMPLETION_TOKEN: Begin completions
376+
// IGNORE_GENERIC_ARGS_AFTER_COMPLETION_TOKEN-DAG: Decl[Struct]/Local: HostRecord[#HostRecord#];
377+
// IGNORE_GENERIC_ARGS_AFTER_COMPLETION_TOKEN: End completions
378+
}
379+
}

0 commit comments

Comments
 (0)