Skip to content

Commit

Permalink
Use SyntheticUnit attachment to detect if has else branch
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed May 17, 2024
1 parent c608177 commit 4d8bf77
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Phases.*
import dotty.tools.dotc.core.Decorators.em
import dotty.tools.dotc.report
import dotty.tools.dotc.ast.Trees.SyntheticUnit

/*
*
Expand Down Expand Up @@ -218,10 +219,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
val success = new asm.Label
val failure = new asm.Label

val hasElse = !elsep.isEmpty && (elsep match {
case Literal(value) if value.tag == UnitTag => false
case _ => true
})
val hasElse = !elsep.hasAttachment(SyntheticUnit)

genCond(condp, success, failure, targetIfNoJump = success)
markProgramPoint(success)
Expand Down

0 comments on commit 4d8bf77

Please # to comment.