Skip to content

Commit 345bfc6

Browse files
committed
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.
1 parent 5101daf commit 345bfc6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ trait ImportSuggestions:
148148
* `name` that are applicable to `T`.
149149
*/
150150
private def importSuggestions(pt: Type)(using Context): (List[TermRef], List[TermRef]) =
151-
val timer = new Timer()
152151
val allotted = ctx.run.nn.importSuggestionBudget
153152
if allotted <= 1 then return (Nil, Nil)
153+
val timer = new Timer()
154154
implicits.println(i"looking for import suggestions, timeout = ${allotted}ms")
155155
val start = System.currentTimeMillis()
156156
val deadLine = start + allotted

0 commit comments

Comments
 (0)