Skip to content

Commit f9e2428

Browse files
Merge pull request #9827 from dotty-staging/backend-getPrimitive
Fix #9775: Fix primitive-in-condition handling in backend
2 parents 61e7370 + c07eab3 commit f9e2428

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
13031303
lineNumber(tree)
13041304
tree match {
13051305

1306-
case tree @ Apply(fun, args) if isPrimitive(fun) =>
1306+
case tree @ Apply(fun, args) if primitives.isPrimitive(fun.symbol) =>
13071307
import ScalaPrimitivesOps.{ ZNOT, ZAND, ZOR, EQ }
13081308

13091309
// lhs and rhs of test
@@ -1321,7 +1321,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
13211321
genCond(rhs, success, failure, targetIfNoJump)
13221322
}
13231323

1324-
primitives.getPrimitive(tree, lhs.tpe) match {
1324+
primitives.getPrimitive(fun.symbol) match {
13251325
case ZNOT => genCond(lhs, failure, success, targetIfNoJump)
13261326
case ZAND => genZandOrZor(and = true)
13271327
case ZOR => genZandOrZor(and = false)

tests/pos/i9775.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait ThreadedImpl {
2+
private val threadSync = new AnyRef
3+
@volatile private var wasClosed = false
4+
5+
private val thread: Thread = ???
6+
val x: Array[Int] = ???
7+
8+
final protected def isThreadRunning: Boolean =
9+
x(0)
10+
// threadSync.synchronized(!wasClosed)
11+
// true
12+
thread.isAlive && threadSync.synchronized(!wasClosed)
13+
}

0 commit comments

Comments
 (0)