File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -457,7 +457,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
457457 * they shouldn't be lifted.
458458 */
459459 val sym = fun.symbol
460- sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt .isCompilerIntrinsic(sym))
460+ sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt .isCompilerIntrinsic(sym) || sym == defn. Object_synchronized )
461461 end
462462
463463 val fun = tree.fun
Original file line number Diff line number Diff line change 1+ // scalac: -coverage-out:coverage
2+ // scalajs: --skip
3+
4+ import concurrent .ExecutionContext .Implicits .global
5+ import scala .concurrent .*
6+ import scala .concurrent .duration .*
7+
8+ var test = 0
9+
10+ def brokenSynchronizedBlock (option : Boolean ): Future [Unit ] = Future {
11+ if (option) {
12+ Thread .sleep(500 )
13+ }
14+ synchronized {
15+ val tmp = test
16+ Thread .sleep(1000 )
17+ test = tmp + 1
18+ }
19+ }
20+
21+ object Test extends App {
22+ Await .result(
23+ Future .sequence(Seq (brokenSynchronizedBlock(false ), brokenSynchronizedBlock(true )))
24+ .map { result =>
25+ println(test)
26+ assert(test == 2 )
27+ },
28+ 3 .seconds
29+ )
30+ }
You can’t perform that action at this time.
0 commit comments