Skip to content

Commit e382789

Browse files
dwijnandWojciechMazur
authored andcommitted
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 345bfc6]
1 parent a89e7d4 commit e382789

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

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

0 commit comments

Comments
 (0)