summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala56
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'.