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 @@ -169,8 +169,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
s eq defn.newArrayMethod
}

def isBox(sym: Symbol): Boolean = Erasure.Boxing.isBox(sym)
def isUnbox(sym: Symbol): Boolean = Erasure.Boxing.isUnbox(sym)
def isBox(sym: Symbol): Boolean =
Erasure.Boxing.isBox(sym) && sym.denot.owner != defn.UnitModuleClass
def isUnbox(sym: Symbol): Boolean =
Erasure.Boxing.isUnbox(sym) && sym.denot.owner != defn.UnitModuleClass

val primitives: Primitives = new Primitives {
val primitives = new DottyPrimitives(ctx)
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ class Definitions {

lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", BoxedUnitType, java.lang.Void.TYPE, UnitEnc, nme.specializedTypeNames.Void)
def UnitClass(implicit ctx: Context) = UnitType.symbol.asClass
def UnitModuleClass(implicit ctx: Context) = UnitType.symbol.asClass.linkedClass
lazy val BooleanType = valueTypeRef("scala.Boolean", BoxedBooleanType, java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean)
def BooleanClass(implicit ctx: Context) = BooleanType.symbol.asClass
lazy val Boolean_notR = BooleanClass.requiredMethodRef(nme.UNARY_!)
Expand Down
4 changes: 4 additions & 0 deletions tests/run/i3518.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
()
()
A
()
12 changes: 12 additions & 0 deletions tests/run/i3518.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object Test {
def main(args: Array[String]): Unit = {
Unit.box(())
Unit.unbox(Unit.box(()))
println(Unit.box(()))
println(Unit.unbox(Unit.box(())))
println(Unit.box({
println("A")
()
}))
}
}