diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-05 09:51:20 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-05 09:51:20 -0800 |
commit | fd4178680643aa064d5a6f7b8e668f79e0be5cd4 (patch) | |
tree | ac7798e9b3e60d09140039fee439630beab983dd /src | |
parent | 01770aa7ff1d5b89a6b67a964a818320c8c9d15e (diff) | |
parent | 9506d5273b4b10037c202f01e8556076998bd064 (diff) | |
download | scala-fd4178680643aa064d5a6f7b8e668f79e0be5cd4.tar.gz scala-fd4178680643aa064d5a6f7b8e668f79e0be5cd4.tar.bz2 scala-fd4178680643aa064d5a6f7b8e668f79e0be5cd4.zip |
Merge pull request #3462 from retronym/ticket/8233
SI-8233 Fix regression in backend with boxed nulls
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 1332d01dbd..9ba38b021d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1007,8 +1007,15 @@ abstract class GenICode extends SubComponent { } // emit conversion - if (generatedType != expectedType) - adapt(generatedType, expectedType, resCtx, tree.pos) + if (generatedType != expectedType) { + tree match { + case Literal(Constant(null)) if generatedType == NullReference => + // literal null on the stack (as opposed to a boxed null, see SI-8233), + // we can bypass `adapt` which would otherwise emitt a redundant [DROP, CONSTANT(null)] + case _ => + adapt(generatedType, expectedType, resCtx, tree.pos) + } + } resCtx } @@ -1058,6 +1065,9 @@ abstract class GenICode extends SubComponent { case (NothingReference, _) => ctx.bb.emit(THROW(ThrowableClass)) ctx.bb.enterIgnoreMode() + case (NullReference, REFERENCE(_)) => + // SI-8223 we can't assume that the stack contains a `null`, it might contain a Null$ + ctx.bb.emit(Seq(DROP(from), CONSTANT(Constant(null)))) case _ if from isAssignabledTo to => () case (_, UNIT) => |