summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2015-08-23 03:55:48 +0200
committerVlad Ureche <vlad.ureche@gmail.com>2015-08-23 15:25:50 +0200
commit6b336f86d677f5aedd40bd673cdd7ffbea780fbd (patch)
tree3021437d1ba7b848c6e126ca10474011ff2b615e /test/files/pos
parentf8a6d21a490090bac20b0753c46b91ca2b335049 (diff)
downloadscala-6b336f86d677f5aedd40bd673cdd7ffbea780fbd.tar.gz
scala-6b336f86d677f5aedd40bd673cdd7ffbea780fbd.tar.bz2
scala-6b336f86d677f5aedd40bd673cdd7ffbea780fbd.zip
SI-9442 Fix the uncurry-erasure types
Using the "uncurry-erased" type (the one after the uncurry phase) can lead to incorrect tree transformations. For example, compiling: ``` def foo(c: Ctx)(l: c.Tree): Unit = { val l2: c.Tree = l } ``` Results in the following AST: ``` def foo(c: Ctx, l: Ctx#Tree): Unit = { val l$1: Ctx#Tree = l.asInstanceOf[Ctx#Tree] val l2: c.Tree = l$1 // no, not really, it's not. } ``` Of course, this is incorrect, since `l$1` has type `Ctx#Tree`, which is not a subtype of `c.Tree`. So what we need to do is to use the pre-uncurry type when creating `l$1`, which is `c.Tree` and is correct. Now, there are two additional problems: 1. when varargs and byname params are involved, the uncurry transformation desugares these special cases to actual typerefs, eg: ``` T* ~> Seq[T] (Scala-defined varargs) T* ~> Array[T] (Java-defined varargs) =>T ~> Function0[T] (by name params) ``` we use the DesugaredParameterType object (defined in scala.reflect.internal.transform.UnCurry) to redo this desugaring manually here 2. the type needs to be normalized, since `gen.mkCast` checks this (no HK here, just aliases have to be expanded before handing the type to `gen.mkAttributedCast`, which calls `gen.mkCast`)
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/t9442.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/files/pos/t9442.scala b/test/files/pos/t9442.scala
new file mode 100644
index 0000000000..2ea81e79cb
--- /dev/null
+++ b/test/files/pos/t9442.scala
@@ -0,0 +1,14 @@
+trait Ctx {
+ trait Tree
+}
+trait Lst[+A] {
+ def zip[A1 >: A, B](that: Lst[B]): Nothing
+}
+class C[@specialized(Int) T] {
+ def moo(t: T) = {
+ def foo1(c: Ctx)(l: Lst[c.Tree]) = l zip l
+ def foo2(c: Ctx)(l: Lst[c.Tree]*) = l(0) zip l(1)
+ def foo3(c: Ctx)(l: => Lst[c.Tree]) = l zip l
+ ???
+ }
+}