summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-10-13 15:39:22 +0000
committerMartin Odersky <odersky@gmail.com>2009-10-13 15:39:22 +0000
commit820e0bd94001e2732b119d217a12844e4720d165 (patch)
tree0307e5751c9b3e2decb605ed7145429887df73d1 /src/compiler
parent04d037f2e1addcd36f0d990c4f1d37106317959e (diff)
downloadscala-820e0bd94001e2732b119d217a12844e4720d165.tar.gz
scala-820e0bd94001e2732b119d217a12844e4720d165.tar.bz2
scala-820e0bd94001e2732b119d217a12844e4720d165.zip
Fixed #2422 abd #2461
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
4 files changed, 13 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 7a6d53b5fb..bcf81c56e6 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -63,7 +63,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
val global: Global.this.type = Global.this
} with TreeGen {
def mkAttributedCast(tree: Tree, pt: Type): Tree =
- typer.typed(mkAttributedCastUntyped(tree, pt))
+ typer.typed(mkCast(tree, pt))
}
/** Fold constants */
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index dfa813b20f..89762ce258 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -131,7 +131,7 @@ abstract class TreeGen
}
/** Cast `tree' to type `pt' */
- def mkAttributedCastUntyped(tree: Tree, pt: Type): Tree = {
+ def mkCast(tree: Tree, pt: Type): Tree = {
if (settings.debug.value) log("casting " + tree + ":" + tree.tpe + " to " + pt)
assert(!tree.tpe.isInstanceOf[MethodType], tree)
assert(!pt.typeSymbol.isPackageClass)
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 12711a36c6..a0afdeabaf 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -392,7 +392,9 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
Select(predef, "wrap"+elemtp.typeSymbol.name+"Array")
else
TypeApply(Select(predef, "genericWrapArray"), List(TypeTree(elemtp)))
- Apply(meth, List(tree))
+ val adaptedTree = // need to cast to Array[elemtp], as arrays are not covariant
+ gen.mkCast(tree, arrayType(elemtp))
+ Apply(meth, List(adaptedTree))
}
}
}
@@ -401,11 +403,15 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
def sequenceToArray(tree: Tree) = {
val toArraySym = tree.tpe member nme.toArray
assert(toArraySym != NoSymbol)
+ def getManifest(tp: Type): Tree = {
+ val manifestOpt = localTyper.findManifest(tp, false)
+ if (!manifestOpt.tree.isEmpty) manifestOpt.tree
+ else if (tp.bounds.hi ne tp) getManifest(tp.bounds.hi)
+ else localTyper.getManifestTree(tree.pos, tp, false)
+ }
atPhase(phase.next) {
localTyper.typedPos(pos) {
- Apply(
- gen.mkAttributedSelect(tree, toArraySym),
- List(localTyper.getManifestTree(tree.pos, tree.tpe.typeArgs.head, false)))
+ Apply(gen.mkAttributedSelect(tree, toArraySym), List(getManifest(tree.tpe.typeArgs.head)))
}
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 7c09df68d3..ebcd18082d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3946,7 +3946,7 @@ trait Typers { self: Analyzer =>
}
def getManifestTree(pos: Position, tp: Type, full: Boolean): Tree = {
- val manifestOpt = findManifest(tp, false)
+ val manifestOpt = findManifest(tp, full)
if (manifestOpt.tree.isEmpty) {
error(pos, "cannot find "+(if (full) "" else "class ")+"manifest for element type "+tp)
Literal(Constant(null))