[IDE] Decrement the global closure discriminator by one before performing the second code completion pass

Otherwise, the closure discriminator will be incremented by one when the closure witht he code completion token is parsed a second time during the second pass, and thus it would receive a different discriminator during the second pass.
This commit is contained in:
Alex Hoppen
2022-12-07 14:47:32 +01:00
parent 0dfcf59a33
commit 1395928d45
2 changed files with 11 additions and 0 deletions

View File

@@ -116,6 +116,11 @@ bool CodeCompletionSecondPassRequest::evaluate(
if (!parserState->hasCodeCompletionDelayedDeclState())
return true;
// Decrement the closure discriminator index by one so a top-level closure
// gets the same discriminator as before when being re-parsed in the second
// pass.
parserState->getTopLevelContext().overrideNextClosureDiscriminator(
parserState->getTopLevelContext().claimNextClosureDiscriminator() - 1);
auto state = parserState->takeCodeCompletionDelayedDeclState();
auto &Ctx = SF->getASTContext();

View File

@@ -0,0 +1,6 @@
// RUN: %sourcekitd-test -req=cursor -pos=4:9 %s -- %s | %FileCheck %s
fileprivate let formatter: DateFormatter = {
let formatter
// CHECK: s:24cursor_in_global_closureXefU_9formatterL_Xevp