summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2014-02-24 14:42:33 +0100
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2014-02-24 14:45:00 +0100
commit7def1a90a01f5ac1e6e4e6b0c0cd58f131874a2f (patch)
tree3568d312ba462cb0b61992cd7d657dc829b48843 /src
parent718a8974f4de14e52006ff152a0f4679fe5318c9 (diff)
downloadscala-7def1a90a01f5ac1e6e4e6b0c0cd58f131874a2f.tar.gz
scala-7def1a90a01f5ac1e6e4e6b0c0cd58f131874a2f.tar.bz2
scala-7def1a90a01f5ac1e6e4e6b0c0cd58f131874a2f.zip
SI-8330: Mismatch in stack heights
The SI-8233 / 9506d52 missed one case when we need to DROP a null from a stack: when unboxed Unit is an expected type. If we forgot to do that in a context where two branches were involved we could end up with unbalanced stack sizes. Let's fix that omission and a test covering that specific case to the original test for SI-8233. Fixes SI-8330.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 81fbbfcabf..1cea4bedda 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1011,9 +1011,10 @@ abstract class GenICode extends SubComponent {
// emit conversion
if (generatedType != expectedType) {
tree match {
- case Literal(Constant(null)) if generatedType == NullReference =>
+ case Literal(Constant(null)) if generatedType == NullReference && expectedType != UNIT =>
// 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)]
+ // except one case: when expected type is UNIT (unboxed) where we need to emit just a DROP
case _ =>
adapt(generatedType, expectedType, resCtx, tree.pos)
}