diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2006-11-14 10:15:34 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2006-11-14 10:15:34 +0000 |
commit | 258064826d62478fa6fb431ffd8f195272824e3a (patch) | |
tree | aa98688c10658695babd412cd1256a0a383e97b7 /src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala | |
parent | d0dd6b7eee6bf0321fd39d43ececb54fe8761334 (diff) | |
download | scala-258064826d62478fa6fb431ffd8f195272824e3a.tar.gz scala-258064826d62478fa6fb431ffd8f195272824e3a.tar.bz2 scala-258064826d62478fa6fb431ffd8f195272824e3a.zip |
Changed BOX/UNBOX to use TypeKind instead of Type.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index e06fd5e2e4..238f9319a7 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -51,15 +51,15 @@ trait TypeKinds requires ICodes { } def toType: Type = this match { - case UNIT => definitions.UnitClass.info - case BOOL => definitions.BooleanClass.info - case BYTE => definitions.ByteClass.info - case SHORT => definitions.ShortClass.info - case CHAR => definitions.CharClass.info - case INT => definitions.IntClass.info - case LONG => definitions.LongClass.info - case FLOAT => definitions.FloatClass.info - case DOUBLE => definitions.DoubleClass.info + case UNIT => definitions.UnitClass.tpe + case BOOL => definitions.BooleanClass.tpe + case BYTE => definitions.ByteClass.tpe + case SHORT => definitions.ShortClass.tpe + case CHAR => definitions.CharClass.tpe + case INT => definitions.IntClass.tpe + case LONG => definitions.LongClass.tpe + case FLOAT => definitions.FloatClass.tpe + case DOUBLE => definitions.DoubleClass.tpe case REFERENCE(cls) => typeRef(cls.typeConstructor.prefix, cls, Nil) case ARRAY(elem) => typeRef(definitions.ArrayClass.typeConstructor.prefix, definitions.ArrayClass, @@ -295,6 +295,44 @@ trait TypeKinds requires ICodes { } + /** A boxed value. */ + case class BOXED(kind: TypeKind) extends TypeKind { + override def toString(): String = + "BOXED(" + kind + ")" + + /** + * Approximate `lub'. The common type of two references is + * always AnyRef. For 'real' least upper bound wrt to subclassing + * use method 'lub'. + */ + override def maxType(other: TypeKind): TypeKind = + other match { + case REFERENCE(_) | ARRAY(_) | BOXED(_) => + REFERENCE(definitions.AnyRefClass) + case _ => + abort("Uncomparbale type kinds: ARRAY with " + other) + } + + /** Checks subtyping relationship. */ + override def <:<(other: TypeKind): Boolean = + other match { + case REFERENCE(sym) => + (sym == definitions.AnyRefClass || + sym == definitions.ObjectClass) // TODO: platform dependent! + + case BOXED(other) => + kind == other + + case _ => false + } + + override def equals(other: Any): Boolean = other match { + case BOXED(kind2) => kind == kind2 + case _ => false + } + + } + /** * Dummy TypeKind to represent the ConcatClass in a platform-independent * way. For JVM it would have been a REFERENCE to 'StringBuffer'. |