Skip to content

Commit

Permalink
Avoid import suggestion thread hang if -Ximport-suggestion-timeout <= 1
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
dwijnand authored and WojciechMazur committed Dec 3, 2024
1 parent a89e7d4 commit e382789
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e382789

Please sign in to comment.