Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
* they shouldn't be lifted.
*/
val sym = fun.symbol
sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt.isCompilerIntrinsic(sym))
sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt.isCompilerIntrinsic(sym) || sym == defn.Object_synchronized)
end

val fun = tree.fun
Expand Down
30 changes: 30 additions & 0 deletions tests/run/i16940.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// scalac: -coverage-out:coverage
// scalajs: --skip

import concurrent.ExecutionContext.Implicits.global
import scala.concurrent.*
import scala.concurrent.duration.*

var test = 0

def brokenSynchronizedBlock(option: Boolean): Future[Unit] = Future {
if (option) {
Thread.sleep(500)
}
synchronized {
val tmp = test
Thread.sleep(1000)
test = tmp + 1
}
}

object Test extends App {
Await.result(
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))
.map { result =>
println(test)
assert(test == 2)
},
3.seconds
)
}