From ef91aa7a705209a81b712c340eafd8bf065b9acb 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. [Cherry-picked 345bfc6639d5db556c8511e5a9ead6724fe37e29] --- 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 5099e7eaf306..1c30f44c29cf 100644 --- a/compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala +++ b/compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala @@ -147,9 +147,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