summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUladzimir Abramchuk <u.abramchuk@gmail.com>2013-02-15 17:19:21 +0300
committerUladzimir Abramchuk <u.abramchuk@gmail.com>2013-04-09 08:48:11 +0300
commit72503126d9c29ff029c4c9537234e1fb1d7a0130 (patch)
tree98169d35afebc835aaa886d2976401ba66695a21
parent58ae1cacdb5fd65bbf876cc6a8d1d1de09e3ce68 (diff)
downloadscala-72503126d9c29ff029c4c9537234e1fb1d7a0130.tar.gz
scala-72503126d9c29ff029c4c9537234e1fb1d7a0130.tar.bz2
scala-72503126d9c29ff029c4c9537234e1fb1d7a0130.zip
SI-6386 typed existential type tree's original now have tpe set
Tree reification fails for ExistentialTypeTree. The reason is that the tree passed for reification (see reifyTree at GetTrees.scala) must have not null tpe (see reifyBoundType at GenTrees.scala), which is not true in the case of ExistentialTypeTree. Why is it so? The tree passed to reifyTree was obtained in the reshape phase of reificationusing using original TypeTrees that reporesent pre- typer representation of a type. The problem is that original's tpe for ExistentialTypeTree is not set. So the solution to the issue is to create ExistentialTypeTree's original in a such way that is has actual tpe set.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala12
-rw-r--r--test/files/pos/t6386.scala5
2 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 34ba8b46f9..d1d6feae97 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3887,8 +3887,16 @@ trait Typers extends Modes with Adaptations with Tags {
if (vd.symbol.tpe.isVolatile)
AbstractionFromVolatileTypeError(vd)
val tpt1 = typedType(tree.tpt, mode)
- existentialTransform(tree.whereClauses map (_.symbol), tpt1.tpe)((tparams, tp) =>
- TypeTree(newExistentialType(tparams, tp)) setOriginal tree
+ existentialTransform(tree.whereClauses map (_.symbol), tpt1.tpe)((tparams, tp) => {
+ val original = tpt1 match {
+ case tpt : TypeTree => atPos(tree.pos)(ExistentialTypeTree(tpt.original, tree.whereClauses))
+ case _ => {
+ debuglog(s"cannot reconstruct the original for $tree, because $tpt1 is not a TypeTree")
+ tree
+ }
+ }
+ TypeTree(newExistentialType(tparams, tp)) setOriginal original
+ }
)
}
diff --git a/test/files/pos/t6386.scala b/test/files/pos/t6386.scala
new file mode 100644
index 0000000000..85098a78f0
--- /dev/null
+++ b/test/files/pos/t6386.scala
@@ -0,0 +1,5 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ reify(manifest[Some[_]])
+} \ No newline at end of file