diff options
author | Martin Odersky <odersky@gmail.com> | 2009-01-29 13:05:53 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-01-29 13:05:53 +0000 |
commit | 9bf8be6db86c0931937d367995a38bddbb5ac727 (patch) | |
tree | b4ecf99c0910f943b101a6047938649fd013d4e4 /src/compiler | |
parent | 7b1258829de818aa1a3893b9ae33afe7cdedbbe8 (diff) | |
download | scala-9bf8be6db86c0931937d367995a38bddbb5ac727.tar.gz scala-9bf8be6db86c0931937d367995a38bddbb5ac727.tar.bz2 scala-9bf8be6db86c0931937d367995a38bddbb5ac727.zip |
1.
Diffstat (limited to 'src/compiler')
4 files changed, 30 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index d5afb77956..70d1a4e521 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -93,6 +93,8 @@ trait Definitions { lazy val TypeConstraintClass: Symbol = getClass("scala.TypeConstraint") lazy val ManifestClass: Symbol = getClass("scala.reflect.Manifest") lazy val ManifestModule: Symbol = getModule("scala.reflect.Manifest") + lazy val OptManifestClass: Symbol = getClass("scala.reflect.OptManifest") + lazy val NoManifest: Symbol = getModule("scala.reflect.NoManifest") var CodeClass: Symbol = _ var CodeModule: Symbol = _ diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index aa532f0cd3..600fcf77a8 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -374,6 +374,7 @@ trait StdNames { val value = newTermName("value") val view_ = newTermName("view") val wait_ = newTermName("wait") + val withDims = newTermName("withDims") val xml = newTermName("xml") val zip = newTermName("zip") diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index b1d334a4b3..d9aa3e89aa 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -37,7 +37,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { * <li>For every other singleton type, the erasure of its supertype.</li> * <li> * For a typeref <code>scala.Array+[T]</code> where <code>T</code> is - * an abstract type, <code>scala.runtime.BoxedArray</code>. + * an abstract type, <code>scala.runtime.BoxedArray[T]</code>. * </li> * <li> * - For a typeref scala.Array+[T] where T is not an abstract type, scala.Array+[|T|]. @@ -592,8 +592,14 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { tree match { case Apply(Select(New(tpt), name), args) if (tpt.tpe.typeSymbol == BoxedArrayClass) => assert(name == nme.CONSTRUCTOR); + val translated = + if (args.length >= 2) { + Select(gen.mkAttributedRef(ArrayModule), nme.withDims) + } else { + Select(New(TypeTree(BoxedAnyArrayClass.tpe)), name) + } atPos(tree.pos) { - Typed(Apply(Select(New(TypeTree(BoxedAnyArrayClass.tpe)), name), args), tpt) + Typed(Apply(translated, args), tpt) } case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List()) if ((tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased)) => diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5a9ac741f6..ecce748314 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2452,7 +2452,7 @@ trait Typers { self: Analyzer => def typedIf(cond: Tree, thenp: Tree, elsep: Tree) = { val cond1 = checkDead(typed(cond, BooleanClass.tpe)) - if (elsep.isEmpty) { + if (elsep.isEmpty) { // in the future, should be unecessary val thenp1 = typed(thenp, UnitClass.tpe) copy.If(tree, cond1, thenp1, elsep) setType UnitClass.tpe } else { @@ -3406,12 +3406,15 @@ trait Typers { self: Analyzer => reportTypeError(tree.pos, ex) setError(tree) case ex: Exception => -// if (settings.debug.value) // @M causes cyclic reference error -// Console.println("exception when typing "+tree+", pt = "+pt) + if (settings.debug.value) // @M causes cyclic reference error + Console.println("exception when typing "+tree+", pt = "+pt) if ((context ne null) && (context.unit ne null) && (context.unit.source ne null) && (tree ne null)) logError("AT: " + (tree.pos).dbgString, ex); throw(ex) + case ex: java.lang.Error => + Console.println("exception when typing "+tree+", pt = "+pt) + throw ex } } @@ -3808,14 +3811,16 @@ trait Typers { self: Analyzer => List() } - def implicitManifest(pt: Type): Tree = { - // test below is designed so that ManifestClass need not be loaded - // (because it's not available everywhere) - if (pt.typeSymbol.fullNameString == "scala.reflect.Manifest") - pt match { - case TypeRef(_, ManifestClass, List(arg)) => manifestOfType(pos, arg) - } - else EmptyTree + def implicitManifest(pt: Type): Tree = pt match { + case TypeRef(_, ManifestClass, List(arg)) => + manifestOfType(pos, arg) + case TypeRef(_, OptManifestClass, List(arg)) => + val tree1 = manifestOfType(pos, arg) + if (tree1 == EmptyTree) gen.mkAttributedRef(NoManifest) else tree1 + case TypeRef(_, tsym, _) if (tsym.isAbstractType) => + implicitManifest(pt.bounds.lo) + case _ => + EmptyTree } var tree = searchImplicit(context.implicitss, true) @@ -3827,7 +3832,9 @@ trait Typers { self: Analyzer => } /** Creates a tree that calls the relevant factory method in object - * reflect.Manifest for type 'tp'. An EmptyTree is returned if */ + * reflect.Manifest for type 'tp'. An EmptyTree is returned if + * no manifest is found + */ def manifestOfType(pos: Position, tp: Type): Tree = { /** Creates a tree that calls the factory method called constructor in object reflect.Manifest */ |