File tree 2 files changed +10
-11
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -487,16 +487,13 @@ trait ImplicitRunInfo:
487
487
*/
488
488
private inline val suggestFirstImplicitsTimeOut = 10000
489
489
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.
497
495
*/
498
- def reduceImportSuggestionTimeout (ms : Long ) =
499
- importSuggestionBudget = (importSuggestionBudget - ms) max (importSuggestionBudget / 2 )
496
+ var importSuggestionBudget : Long = 10000
500
497
501
498
private def isExcluded (sym : Symbol ) =
502
499
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:
142
142
*/
143
143
private def importSuggestions (pt : Type )(using Context ): (List [TermRef ], List [TermRef ]) =
144
144
val timer = new Timer ()
145
- val allotted = ctx.run.nextImportSuggestionTimeout()
145
+ val allotted = ctx.run.importSuggestionBudget
146
146
if allotted <= 1 then return (Nil , Nil )
147
147
implicits.println(i " looking for import suggestions, timeout = ${allotted}ms " )
148
148
val start = System .currentTimeMillis()
@@ -252,7 +252,9 @@ trait ImportSuggestions:
252
252
(Nil , Nil )
253
253
finally
254
254
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 )
256
258
end importSuggestions
257
259
258
260
/** The `ref` parts of this list of pairs, discarding subsequent elements that
You can’t perform that action at this time.
0 commit comments