File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -487,16 +487,13 @@ trait ImplicitRunInfo:
487487 */
488488 private inline val suggestFirstImplicitsTimeOut = 10000
489489
490- private var importSuggestionBudget : Long = suggestFirstImplicitsTimeOut
491-
492- /** The current timeout for import suggestions */
493- def nextImportSuggestionTimeout () = importSuggestionBudget
494-
495- /** Reduce the import suggestion timeout by `ms`, but make sure that
496- * the new timeout is at least half the old one.
490+ /** Global default timeout to stop looking for further implicit suggestions, in ms.
491+ * This is usually for the first import suggestion; subsequent suggestions
492+ * may get smaller timeouts. Specifically, the importSuggestions method reduces
493+ * the budget available after it is run by the time it took, but never less
494+ * than to half of the previous budget.
497495 */
498- def reduceImportSuggestionTimeout (ms : Long ) =
499- importSuggestionBudget = (importSuggestionBudget - ms) max (importSuggestionBudget / 2 )
496+ var importSuggestionBudget : Long = 10000
500497
501498 private def isExcluded (sym : Symbol ) =
502499 if migrateTo3 then false else sym.is(Package ) || sym.isPackageObject
Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ trait ImportSuggestions:
142142 */
143143 private def importSuggestions (pt : Type )(using Context ): (List [TermRef ], List [TermRef ]) =
144144 val timer = new Timer ()
145- val allotted = ctx.run.nextImportSuggestionTimeout()
145+ val allotted = ctx.run.importSuggestionBudget
146146 if allotted <= 1 then return (Nil , Nil )
147147 implicits.println(i " looking for import suggestions, timeout = ${allotted}ms " )
148148 val start = System .currentTimeMillis()
@@ -252,7 +252,9 @@ trait ImportSuggestions:
252252 (Nil , Nil )
253253 finally
254254 timer.cancel()
255- ctx.run.reduceImportSuggestionTimeout(System .currentTimeMillis() - start)
255+ ctx.run.importSuggestionBudget =
256+ (ctx.run.importSuggestionBudget - (System .currentTimeMillis() - start))
257+ `max` (ctx.run.importSuggestionBudget / 2 )
256258 end importSuggestions
257259
258260 /** The `ref` parts of this list of pairs, discarding subsequent elements that
You can’t perform that action at this time.
0 commit comments