diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala | 31 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 95c7876408..32dcf06365 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1053,7 +1053,7 @@ abstract class GenICode extends SubComponent { private def genLoadQualifier(tree: Tree, ctx: Context): Context = tree match { case Select(qualifier, _) => - genLoad(qualifier, ctx, ANY_REF_CLASS) // !! + genLoad(qualifier, ctx, toTypeKind(qualifier.tpe)) case _ => abort("Unknown qualifier " + tree) } 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 |