From 23a59cf62969eb4f0ba46b6e3e3567f0697050d3 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Mon, 27 Nov 2006 13:27:44 +0000 Subject: Fixed bug ivolving corecions and default conver... Fixed bug ivolving corecions and default conversions. --- src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala | 11 +++++++++++ src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index c544aa8337..b665e3fbc1 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -546,6 +546,17 @@ abstract class ScalaPrimitives { case _ => false } + /** If code is a coercion primitive, the result type */ + def generatedKind(code: Int): TypeKind = code match { + case B2B | C2B | S2B | I2B | L2B | F2B | D2B => BYTE + case B2C | C2C | S2C | I2C | L2C | F2C | D2C => CHAR + case B2S | C2S | S2S | I2S | L2S | F2S | D2S => SHORT + case B2I | C2I | S2I | I2I | L2I | F2I | D2I => INT + case B2L | C2L | S2L | I2L | L2L | F2L | D2L => LONG + case B2F | C2F | S2F | I2F | L2F | F2F | D2F => FLOAT + case B2D | C2D | S2D | I2D | L2D | F2D | D2D => DOUBLE + } + def isPrimitive(sym: Symbol): Boolean = primitives contains sym /** Return the code for the givem symbol. */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index abb417d230..b355ebaa6d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -747,6 +747,7 @@ abstract class GenICode extends SubComponent { } else if (scalaPrimitives.isCoercion(code)) { ctx1 = genLoad(receiver, ctx1, toTypeKind(receiver.tpe)) genCoercion(tree, ctx1, code) + generatedType = scalaPrimitives.generatedKind(code) } else abort("Primitive operation not handled yet: " + fun.symbol.fullNameString + "(" + fun.symbol.simpleName + ") " @@ -1094,10 +1095,7 @@ abstract class GenICode extends SubComponent { /** Is the given symbol a primitive operation? */ def isPrimitive(fun: Symbol): Boolean = scalaPrimitives.isPrimitive(fun) - /** - * @param tree ... - * @param ctx ... - * @param code ... + /** Generate coercion denoted by "code" */ def genCoercion(tree: Tree, ctx: Context, code: Int) = { import scalaPrimitives._ -- cgit v1.2.3