diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-13 05:13:16 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-13 05:13:16 -0700 |
commit | 184e0cc126c9499ea7572621663b14c37dba4734 (patch) | |
tree | 43832424e3150a4e34b0e5e37fccc4e76c80d4d9 /test | |
parent | ac51ccdea40dc39fe1ae278e9b9b45d1e7679baf (diff) | |
parent | 5f324591a4c4af53f27a64932b843ba1423c37cd (diff) | |
download | scala-184e0cc126c9499ea7572621663b14c37dba4734.tar.gz scala-184e0cc126c9499ea7572621663b14c37dba4734.tar.bz2 scala-184e0cc126c9499ea7572621663b14c37dba4734.zip |
Merge pull request #2242 from adriaanm/merge-2.10.x
Merge 2.10.x into master
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t7235.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7235.scala | 14 | ||||
-rw-r--r-- | test/files/neg/t7238.check | 6 | ||||
-rw-r--r-- | test/files/neg/t7238.scala | 7 | ||||
-rw-r--r-- | test/files/pos/t7226.scala | 26 | ||||
-rw-r--r-- | test/files/pos/t7234.scala | 15 | ||||
-rw-r--r-- | test/files/pos/t7234b.scala | 20 | ||||
-rw-r--r-- | test/files/presentation/hyperlinks.check | 137 | ||||
-rw-r--r-- | test/files/presentation/hyperlinks/src/SuperTypes.scala | 32 | ||||
-rw-r--r-- | test/files/run/t5710-1.check | 1 | ||||
-rw-r--r-- | test/files/run/t5710-1.scala | 15 | ||||
-rw-r--r-- | test/files/run/t5710-2.check | 1 | ||||
-rw-r--r-- | test/files/run/t5710-2.scala | 15 | ||||
-rw-r--r-- | test/files/run/t7235.check | 4 | ||||
-rw-r--r-- | test/files/run/t7235.scala | 14 |
15 files changed, 310 insertions, 1 deletions
diff --git a/test/files/neg/t7235.check b/test/files/neg/t7235.check new file mode 100644 index 0000000000..357a3dfd83 --- /dev/null +++ b/test/files/neg/t7235.check @@ -0,0 +1,4 @@ +t7235.scala:9: error: implementation restriction: cannot reify refinement type trees with non-empty bodies + val Block(List(ValDef(_, _, tpt: CompoundTypeTree, _)), _) = reify{ val x: C { def x: Int } = ??? }.tree + ^ +one error found diff --git a/test/files/neg/t7235.scala b/test/files/neg/t7235.scala new file mode 100644 index 0000000000..cfebad3fae --- /dev/null +++ b/test/files/neg/t7235.scala @@ -0,0 +1,14 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +class C + +object Test extends App { + val Block(List(ValDef(_, _, tpt: CompoundTypeTree, _)), _) = reify{ val x: C { def x: Int } = ??? }.tree + println(tpt) + println(tpt.templ.parents) + println(tpt.templ.self) + println(tpt.templ.body) +} diff --git a/test/files/neg/t7238.check b/test/files/neg/t7238.check new file mode 100644 index 0000000000..b87f83ff65 --- /dev/null +++ b/test/files/neg/t7238.check @@ -0,0 +1,6 @@ +t7238.scala:6: error: type mismatch; + found : Seq[Any] + required: Seq[String] + c.c()(Seq[Any](): _*) + ^ +one error found diff --git a/test/files/neg/t7238.scala b/test/files/neg/t7238.scala new file mode 100644 index 0000000000..d42dc8d385 --- /dev/null +++ b/test/files/neg/t7238.scala @@ -0,0 +1,7 @@ +trait Main { + trait C { + def c(x: Any = 0)(bs: String*) + } + def c: C + c.c()(Seq[Any](): _*) +} diff --git a/test/files/pos/t7226.scala b/test/files/pos/t7226.scala new file mode 100644 index 0000000000..06f0c95dc4 --- /dev/null +++ b/test/files/pos/t7226.scala @@ -0,0 +1,26 @@ +trait HK { + type Rep[X] + + // okay + def unzip2[A, B](ps: Rep[List[(A, B)]]) + unzip2(null.asInstanceOf[Rep[List[(Int, String)]]]) + + // okay + def unzipHK[A, B, C[_]](ps: Rep[C[(A, B)]]) + unzipHK(null.asInstanceOf[Rep[List[(Int, String)]]]) + + def unzipHKRet0[A, C[_]](ps: C[A]): C[Int] + def ls: List[String] + unzipHKRet0(ls) + + // fail + def unzipHKRet[A, C[_]](ps: Rep[C[A]]): Rep[C[Int]] + def rls: Rep[List[String]] + unzipHKRet(rls) +} + +trait HK1 { + type Rep[A] + def unzip1[A, B, C[_]](ps: Rep[C[(A, B)]]): (Rep[C[A]], Rep[C[B]]) + def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1(ps) +} diff --git a/test/files/pos/t7234.scala b/test/files/pos/t7234.scala new file mode 100644 index 0000000000..59a233d835 --- /dev/null +++ b/test/files/pos/t7234.scala @@ -0,0 +1,15 @@ +trait Main { + trait A { + type B + } + trait C { + def c(a: A, x: Int = 0)(b: a.B) + } + def c: C + def d(a: A, x: Int = 0)(b: a.B) + + def ok1(a: A)(b: a.B) = c.c(a, 42)(b) + def ok2(a: A)(b: a.B) = d(a)(b) + + def fail(a: A)(b: a.B) = c.c(a)(b) +} diff --git a/test/files/pos/t7234b.scala b/test/files/pos/t7234b.scala new file mode 100644 index 0000000000..fee98e87a8 --- /dev/null +++ b/test/files/pos/t7234b.scala @@ -0,0 +1,20 @@ +trait Main { + trait A { + type B + def b: B + } + trait C { + def c(a: A, x: Int = 0)(b: => a.B, bs: a.B*) + def d(a: A = null, x: Int = 0)(b1: => a.B = a.b, b2: a.B = a.b) + } + def c: C + def ok(a: A)(b: a.B) = c.c(a, 42)(b) + def fail(a: A)(b: a.B) = c.c(a)(b) + def fail2(a: A)(b: a.B) = c.c(a)(b, b) + def fail3(a: A)(b: a.B) = c.c(a)(b, Seq[a.B](b): _*) + + def fail4(a: A)(b: a.B) = c.d(a)() + def fail5(a: A)(b: a.B) = c.d(a)(b1 = a.b) + def fail6(a: A)(b: a.B) = c.d(a)(b2 = a.b) + def fail7(a: A)(b: a.B) = c.d()() +} diff --git a/test/files/presentation/hyperlinks.check b/test/files/presentation/hyperlinks.check index 85d295dd7d..1051b67e85 100644 --- a/test/files/presentation/hyperlinks.check +++ b/test/files/presentation/hyperlinks.check @@ -1,4 +1,4 @@ -reload: NameDefaultTests.scala, PatMatTests.scala +reload: NameDefaultTests.scala, PatMatTests.scala, SuperTypes.scala askHyperlinkPos for `someOtherInt` at (14,24) NameDefaultTests.scala ================================================================================ @@ -44,3 +44,138 @@ askHyperlinkPos for `y` at (25,21) PatMatTests.scala ================================================================================ [response] found askHyperlinkPos for `y` at (23,13) PatMatTests.scala ================================================================================ + +askHyperlinkPos for `BadPos` at (10,26) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `BadPos` at (2,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `BadPos` at (11,26) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `BadPos` at (2,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `Trait` at (12,25) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `Trait` at (6,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `SubTrait` at (13,28) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `SubTrait` at (7,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `Trait` at (14,25) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `Trait` at (6,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `LateralTrait` at (14,48) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `LateralTrait` at (8,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `Base` at (15,24) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `Base` at (4,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `Trait` at (15,40) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `Trait` at (6,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `LateralTrait` at (15,63) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `LateralTrait` at (8,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PBase` at (19,29) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PBase` at (17,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (20,33) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PBase` at (21,36) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PBase` at (17,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (23,27) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PSubTrait` at (24,30) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PSubTrait` at (20,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (25,27) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PLateralTrait` at (25,56) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PLateralTrait` at (21,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PBase` at (26,26) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PBase` at (17,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (26,48) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PLateralTrait` at (26,77) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PLateralTrait` at (21,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `BadPos` at (28,23) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `BadPos` at (2,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (29,23) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PSubTrait` at (30,26) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PSubTrait` at (20,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (31,23) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PLateralTrait` at (31,52) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PLateralTrait` at (21,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PBase` at (32,22) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PBase` at (17,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PTrait` at (32,44) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PTrait` at (19,7) SuperTypes.scala +================================================================================ + +askHyperlinkPos for `PLateralTrait` at (32,73) SuperTypes.scala +================================================================================ +[response] found askHyperlinkPos for `PLateralTrait` at (21,7) SuperTypes.scala +================================================================================ diff --git a/test/files/presentation/hyperlinks/src/SuperTypes.scala b/test/files/presentation/hyperlinks/src/SuperTypes.scala new file mode 100644 index 0000000000..15d16069fd --- /dev/null +++ b/test/files/presentation/hyperlinks/src/SuperTypes.scala @@ -0,0 +1,32 @@ +/** This tests that hyperlinking works for super types. See SI-7224 */ +class BadPos[A](a: A) + +class Base + +trait Trait extends Base +trait SubTrait extends Trait +trait LateralTrait extends Base + +object obj1 extends BadPos/*#*/(new Object) +object obj2 extends BadPos/*#*/[AnyRef](new Object) +object obj3 extends Trait/*#*/ +object obj4 extends SubTrait/*#*/ +object obj5 extends Trait/*#*/ with LateralTrait/*#*/ +object obj6 extends Base/*#*/ with Trait/*#*/ with LateralTrait/*#*/ + +class PBase[A] + +trait PTrait[A] extends PBase/*#*/[A] +trait PSubTrait[A] extends PTrait/*#*/[A] +trait PLateralTrait[A] extends PBase/*#*/[A] + +object pobj2 extends PTrait/*#*/[Int] +object pobj3 extends PSubTrait/*#*/[Int] +object pobj4 extends PTrait/*#*/[Int] with PLateralTrait/*#*/[Int] +object pobj5 extends PBase/*#*/[Int] with PTrait/*#*/[Int] with PLateralTrait/*#*/[Int] + +class c1 extends BadPos/*#*/(new Object) +class c2 extends PTrait/*#*/[Int] +class c3 extends PSubTrait/*#*/[Int] +class c4 extends PTrait/*#*/[Int] with PLateralTrait/*#*/[Int] +class c5 extends PBase/*#*/[Int] with PTrait/*#*/[Int] with PLateralTrait/*#*/[Int] diff --git a/test/files/run/t5710-1.check b/test/files/run/t5710-1.check new file mode 100644 index 0000000000..eac2025aeb --- /dev/null +++ b/test/files/run/t5710-1.check @@ -0,0 +1 @@ +evaluated = (abc,abc) diff --git a/test/files/run/t5710-1.scala b/test/files/run/t5710-1.scala new file mode 100644 index 0000000000..12bd858e06 --- /dev/null +++ b/test/files/run/t5710-1.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val code = reify { + val (x, y) = ("abc": Any) match { case x => (x, x) } + (x, y) + }; + + val toolbox = cm.mkToolBox() + val evaluated = toolbox.eval(code.tree) + println("evaluated = " + evaluated) +}
\ No newline at end of file diff --git a/test/files/run/t5710-2.check b/test/files/run/t5710-2.check new file mode 100644 index 0000000000..eac2025aeb --- /dev/null +++ b/test/files/run/t5710-2.check @@ -0,0 +1 @@ +evaluated = (abc,abc) diff --git a/test/files/run/t5710-2.scala b/test/files/run/t5710-2.scala new file mode 100644 index 0000000000..6d2129cca2 --- /dev/null +++ b/test/files/run/t5710-2.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val code = reify { + val (x, y) = "abc" match { case x => (x, x) } + (x, y) + }; + + val toolbox = cm.mkToolBox() + val evaluated = toolbox.eval(code.tree) + println("evaluated = " + evaluated) +}
\ No newline at end of file diff --git a/test/files/run/t7235.check b/test/files/run/t7235.check new file mode 100644 index 0000000000..9cb9c55a0c --- /dev/null +++ b/test/files/run/t7235.check @@ -0,0 +1,4 @@ +C +List(C) +private val _ = _ +List() diff --git a/test/files/run/t7235.scala b/test/files/run/t7235.scala new file mode 100644 index 0000000000..6039189716 --- /dev/null +++ b/test/files/run/t7235.scala @@ -0,0 +1,14 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +class C + +object Test extends App { + val Block(List(ValDef(_, _, tpt: CompoundTypeTree, _)), _) = reify{ val x: C{} = ??? }.tree + println(tpt) + println(tpt.templ.parents) + println(tpt.templ.self) + println(tpt.templ.body) +} |