Skip to content

Commit 1cd30d2

Browse files
committed
Fix #8072: Synchronize cancelling timer task properly
Concurrent programming is hard ... I tested that it works now by setting the timeout from 500 to 1. I gots lots of cancellations but no discrepancies in the error counts.
1 parent 5a86c1f commit 1cd30d2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,11 @@ trait ImportSuggestions with
186186
typedImplicit(candidate, expectedType, argument, span)(
187187
given ctx.fresh.setExploreTyperState()).isSuccess
188188
finally
189-
task.cancel()
190-
ctx.run.isCancelled = false
189+
if task.cancel() then // timer task has not run yet
190+
assert(!ctx.run.isCancelled)
191+
else
192+
while !ctx.run.isCancelled do () // wait until timer task has run to completion
193+
ctx.run.isCancelled = false
191194
}
192195
end deepTest
193196

0 commit comments

Comments
 (0)