summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-09-21 11:06:54 +0000
committerMartin Odersky <odersky@gmail.com>2006-09-21 11:06:54 +0000
commit3b48a0dbda5b032e611301e0f17acdbce2c59880 (patch)
tree990e21147c4cd351912874700d1c44636755874d
parent2282fe8e8d2e16679aa4a612fdf2fc410006759d (diff)
downloadscala-3b48a0dbda5b032e611301e0f17acdbce2c59880.tar.gz
scala-3b48a0dbda5b032e611301e0f17acdbce2c59880.tar.bz2
scala-3b48a0dbda5b032e611301e0f17acdbce2c59880.zip
fixed bug748;
improved display of `new' in TreePrinters
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreePrinters.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala10
2 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
index af48d27daa..0a2a5eb1d6 100644
--- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
@@ -277,6 +277,10 @@ abstract class TreePrinters {
if (!qual.isEmpty) print(symName(tree, qual) + ".")
print("this")
+ case Select(qual @ New(tpe), name) =>
+ assert(tree.symbol == null || tree.symbol.isConstructor)
+ print(qual)
+
case Select(qualifier, name) =>
print(qualifier); print("."); print(symName(tree, name))
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index d33da6a548..0e15ca8d45 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -226,6 +226,12 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
}
}
+ /** Generate a cast operation from `tree.tpe' to `pt'.
+ * The following cases need to be treated specially:
+ * Object -> Array (might be a boxedarray)
+ * Object -> Boxed*Array (might be an array, which nees to be boxed)
+ * Object -> Seq, Iterable (might be an array, which needs to be boxed)
+ */
private def cast(tree: Tree, pt: Type): Tree =
if (pt.symbol == ArrayClass && tree.tpe.symbol == ObjectClass)
typed {
@@ -243,7 +249,9 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
pt))
}
}
- else if (pt.symbol.isNonBottomSubClass(BoxedArrayClass) && tree.tpe.symbol == ObjectClass)
+ else if ((pt.symbol.isNonBottomSubClass(BoxedArrayClass) ||
+ pt.symbol != ObjectClass && SeqClass.isNonBottomSubClass(pt.symbol)) &&
+ tree.tpe.symbol == ObjectClass)
typed {
atPos(tree.pos) {
evalOnce(tree, x =>