diff options
author | Szabolcs Berecz <szabolcs.berecz@gmail.com> | 2012-02-20 21:34:55 +0100 |
---|---|---|
committer | Szabolcs Berecz <szabolcs.berecz@gmail.com> | 2012-02-20 23:36:54 +0100 |
commit | 61c9b4f01d99a81e15391b270bd1b5a895f65ffd (patch) | |
tree | 359881a8e9de12c6ae867cd2f0cfbd2830f5fc2a /src/compiler | |
parent | a6a9684f5ba5df146be1f24bd170e97f0b2208ce (diff) | |
download | scala-61c9b4f01d99a81e15391b270bd1b5a895f65ffd.tar.gz scala-61c9b4f01d99a81e15391b270bd1b5a895f65ffd.tar.bz2 scala-61c9b4f01d99a81e15391b270bd1b5a895f65ffd.zip |
Fix for SI-5215 part 2: generate return value when eliding method calls
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index ca00508dc7..e1731c5259 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -880,6 +880,20 @@ abstract class GenICode extends SubComponent { // XXX settings.noassertions.value temporarily retained to avoid // breakage until a reasonable interface is settled upon. debuglog("Eliding call from " + tree.symbol.owner + " to " + sym + " based on its elision threshold of " + sym.elisionLevel.get) + val value = expectedType match { + case UNIT => () + case BOOL => false + case BYTE => 0:Byte + case SHORT => 0:Short + case CHAR => '?' + case INT => 0 + case LONG => 0L + case FLOAT => 0.0f + case DOUBLE => 0.0 + case _ => null + } + ctx.bb.emit(CONSTANT(Constant(value)), tree.pos) + generatedType = if (expectedType.isInstanceOf[ValueTypeKind]) expectedType else NullReference ctx } else { // normal method call debuglog("Gen CALL_METHOD with sym: " + sym + " isStaticSymbol: " + sym.isStaticMember); |