From 345bfc6639d5db556c8511e5a9ead6724fe37e29 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sun, 25 Aug 2024 16:23:33 +0100 Subject: [PATCH] Avoid import suggestion thread hang if -Ximport-suggestion-timeout <= 1 Without this change, if -Ximport-suggestion-timeout is set to 0 or 1, we would create a Timer thread and never cancel it, making the whole execution thread hang. --- compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala b/compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala index 5ab6a4a5fae6..8f8c51e2f566 100644 --- a/compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala +++ b/compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala @@ -148,9 +148,9 @@ trait ImportSuggestions: * `name` that are applicable to `T`. */ private def importSuggestions(pt: Type)(using Context): (List[TermRef], List[TermRef]) = - val timer = new Timer() val allotted = ctx.run.nn.importSuggestionBudget if allotted <= 1 then return (Nil, Nil) + val timer = new Timer() implicits.println(i"looking for import suggestions, timeout = ${allotted}ms") val start = System.currentTimeMillis() val deadLine = start + allotted