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.scala31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
index 4e2527bc3e..35675f5417 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
@@ -412,7 +412,11 @@ trait TypeKinds { self: ICodes =>
/** Return the TypeKind of the given type */
def toTypeKind(t: Type): TypeKind = t.normalize match {
- case ThisType(sym) => REFERENCE(sym)
+ case ThisType(sym) =>
+ if (sym == definitions.ArrayClass)
+ AnyRefReference
+ else
+ REFERENCE(sym)
case SingleType(pre, sym) =>
primitiveTypeMap get sym match {
@@ -426,17 +430,7 @@ trait TypeKinds { self: ICodes =>
case TypeRef(_, sym, args) =>
primitiveTypeMap get sym match {
case Some(k) => k
- case None =>
- if (sym == definitions.ArrayClass)
- ARRAY(toTypeKind(args.head))
- else {
- if (sym.isClass)
- REFERENCE(sym)
- else {
- assert(sym.isType, sym) // it must be compiling Array[a]
- AnyRefReference
- }
- }
+ case None => arrayOrClassType(sym, args)
}
case ClassInfoType(_, _, sym) =>
@@ -459,6 +453,19 @@ trait TypeKinds { self: ICodes =>
abort("Unknown type: " + t)
}
+ /** Return the type kind of a class, possibly an array type.
+ */
+ private def arrayOrClassType(sym: Symbol, targs: List[Type]): TypeKind = {
+ if (sym == definitions.ArrayClass)
+ ARRAY(toTypeKind(targs.head))
+ else if (sym.isClass)
+ REFERENCE(sym)
+ else {
+ assert(sym.isType, sym) // it must be compiling Array[a]
+ AnyRefReference
+ }
+ }
+
/** A map from scala primitive Types to ICode TypeKinds */
private var primitiveTypeMap: Map[Symbol, TypeKind] = null