diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t3275.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3275.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t5455.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5455.scala | 16 | ||||
-rw-r--r-- | test/files/neg/t5553_1.check | 54 | ||||
-rw-r--r-- | test/files/neg/t5553_1.scala | 34 | ||||
-rw-r--r-- | test/files/neg/t5553_2.check | 50 | ||||
-rw-r--r-- | test/files/neg/t5553_2.scala | 59 | ||||
-rw-r--r-- | test/files/neg/t5554.check | 67 | ||||
-rw-r--r-- | test/files/neg/t5554.scala | 39 | ||||
-rw-r--r-- | test/files/neg/tailrec-2.check | 7 | ||||
-rw-r--r-- | test/files/neg/tailrec-2.scala | 3 | ||||
-rw-r--r-- | test/files/pos/t5546.scala | 1 | ||||
-rw-r--r-- | test/files/run/manifests.scala | 19 | ||||
-rw-r--r-- | test/files/run/t3569.check | 17 | ||||
-rw-r--r-- | test/files/run/t3569.flags | 1 | ||||
-rw-r--r-- | test/files/run/t3569.scala | 32 | ||||
-rw-r--r-- | test/files/run/t5545.check | 0 | ||||
-rw-r--r-- | test/files/run/t5545.scala | 27 |
19 files changed, 430 insertions, 7 deletions
diff --git a/test/files/neg/t3275.check b/test/files/neg/t3275.check new file mode 100644 index 0000000000..117c792321 --- /dev/null +++ b/test/files/neg/t3275.check @@ -0,0 +1,4 @@ +t3275.scala:2: error: @tailrec annotated method contains no recursive calls + @annotation.tailrec def foo() = 5 + ^ +one error found diff --git a/test/files/neg/t3275.scala b/test/files/neg/t3275.scala new file mode 100644 index 0000000000..18e38a1a97 --- /dev/null +++ b/test/files/neg/t3275.scala @@ -0,0 +1,3 @@ +object Test { + @annotation.tailrec def foo() = 5 +} diff --git a/test/files/neg/t5455.check b/test/files/neg/t5455.check new file mode 100644 index 0000000000..788daf99fa --- /dev/null +++ b/test/files/neg/t5455.check @@ -0,0 +1,4 @@ +t5455.scala:4: error: lazy vals are not tailcall transformed + @annotation.tailrec final lazy val bar: Thing[Int] = { + ^ +one error found diff --git a/test/files/neg/t5455.scala b/test/files/neg/t5455.scala new file mode 100644 index 0000000000..22d6c442c9 --- /dev/null +++ b/test/files/neg/t5455.scala @@ -0,0 +1,16 @@ +trait Test { + def root: Test + + @annotation.tailrec final lazy val bar: Thing[Int] = { + if (this eq root) + Thing(() => System.identityHashCode(bar)) + else + root.bar + } + + def f = bar.f() +} + +case class Thing[A](f: () => A) { + override def toString = "" + f() +} diff --git a/test/files/neg/t5553_1.check b/test/files/neg/t5553_1.check new file mode 100644 index 0000000000..afd6489888 --- /dev/null +++ b/test/files/neg/t5553_1.check @@ -0,0 +1,54 @@ +t5553_1.scala:18: error: ambiguous reference to overloaded definition, +both method apply in object Foo1 of type (z: String)Base[T] +and method apply in object Foo1 of type (a: Int)Base[T] +match expected type ? + def test1[T] = Foo1[T] + ^ +t5553_1.scala:19: error: type mismatch; + found : [T](z: String)Base[T] <and> (a: Int)Base[T] + required: Int + def test2[T]: Int = Foo1[T] + ^ +t5553_1.scala:20: error: type mismatch; + found : [T(in method apply)](z: String)Base[T(in method apply)] <and> (a: Int)Base[T(in method apply)] + required: Base[T(in method test3)] + def test3[T]: Base[T] = Foo1[T] + ^ +t5553_1.scala:24: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (z: String)Base[T] +and method apply in object Foo2 of type (a: Int)Base[T] +match expected type ? + def test4[T] = Foo2[T] + ^ +t5553_1.scala:25: error: type mismatch; + found : [T](z: String)Base[T] <and> (a: Int)Base[T] + required: Int + def test5[T]: Int = Foo2[T] + ^ +t5553_1.scala:26: error: type mismatch; + found : [T(in method apply)](z: String)Base[T(in method apply)] <and> (a: Int)Base[T(in method apply)] + required: Base[T(in method test6)] + def test6[T]: Base[T] = Foo2[T] + ^ +t5553_1.scala:30: error: ambiguous reference to overloaded definition, +both method apply in object Foo3 of type (z: String)String +and method apply in object Foo3 of type (a: Int)Base[T] +match expected type ? + def test7[T] = Foo3[T] + ^ +t5553_1.scala:31: error: type mismatch; + found : [T](z: String)String <and> (a: Int)Base[T] + required: String + def test8[T]: String = Foo3[T] + ^ +t5553_1.scala:32: error: type mismatch; + found : [T](z: String)String <and> (a: Int)Base[T] + required: Int + def test9[T]: Int = Foo3[T] + ^ +t5553_1.scala:33: error: type mismatch; + found : [T(in method apply)](z: String)String <and> (a: Int)Base[T(in method apply)] + required: Base[T(in method test10)] + def test10[T]: Base[T] = Foo3[T] + ^ +10 errors found diff --git a/test/files/neg/t5553_1.scala b/test/files/neg/t5553_1.scala new file mode 100644 index 0000000000..32d61ec852 --- /dev/null +++ b/test/files/neg/t5553_1.scala @@ -0,0 +1,34 @@ +class Base[T] + +object Foo1 { + def apply[T](a: Int): Base[T] = new Base[T] + def apply[T](z: String): Base[T] = new Base[T] +} + +object Foo2 { + def apply[T](a: Int): Base[T] = new Base[T] + def apply[T](z: String="abc"): Base[T] = new Base[T] +} + +object Foo3 { + def apply[T](a: Int): Base[T] = new Base[T] + def apply[T](z: String="abc"): String = z +} +object Test { + def test1[T] = Foo1[T] + def test2[T]: Int = Foo1[T] + def test3[T]: Base[T] = Foo1[T] +} + +object Test2 { + def test4[T] = Foo2[T] + def test5[T]: Int = Foo2[T] + def test6[T]: Base[T] = Foo2[T] +} + +object Test3{ + def test7[T] = Foo3[T] + def test8[T]: String = Foo3[T] + def test9[T]: Int = Foo3[T] + def test10[T]: Base[T] = Foo3[T] +} diff --git a/test/files/neg/t5553_2.check b/test/files/neg/t5553_2.check new file mode 100644 index 0000000000..599fdb0523 --- /dev/null +++ b/test/files/neg/t5553_2.check @@ -0,0 +1,50 @@ +t5553_2.scala:27: error: type mismatch; + found : Base[T] + required: Int + def test4[T]: Int = Foo1[T](1) + ^ +t5553_2.scala:34: error: type mismatch; + found : String + required: Base[T] + def test7[T]: Base[T] = Foo2[T] + ^ +t5553_2.scala:35: error: type mismatch; + found : String + required: Int + def test8[T]: Int = Foo2[T] + ^ +t5553_2.scala:40: error: type mismatch; + found : String + required: Int + def test9[T]: Int = Foo3[T] + ^ +t5553_2.scala:41: error: type mismatch; + found : String + required: Base[T] + def test10[T]: Base[T] = Foo3[T] + ^ +t5553_2.scala:47: error: could not find implicit value for parameter z: String + def test13[T]: Int = Foo3[T] + ^ +t5553_2.scala:48: error: could not find implicit value for parameter z: String + def test14[T]: Base[T] = Foo3[T] + ^ +t5553_2.scala:49: error: could not find implicit value for parameter z: String + def test15[T]: String = Foo3[T] + ^ +t5553_2.scala:50: error: could not find implicit value for parameter z: String + def test16[T] = Foo3[T] + ^ +t5553_2.scala:54: error: ambiguous reference to overloaded definition, +both method apply in object Foo4 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo4 of type (x: Int)Base[T] +match argument types (Int) + def test17[T] = Foo4[T](1) + ^ +t5553_2.scala:55: error: ambiguous reference to overloaded definition, +both method apply in object Foo4 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo4 of type (x: Int)Base[T] +match argument types (Int) and expected result type Base[T] + def test18[T]: Base[T] = Foo4[T](1) + ^ +11 errors found diff --git a/test/files/neg/t5553_2.scala b/test/files/neg/t5553_2.scala new file mode 100644 index 0000000000..16958aec8e --- /dev/null +++ b/test/files/neg/t5553_2.scala @@ -0,0 +1,59 @@ +class Base[T] + +object Foo1 { + def apply[T](x: Int): Base[T] = new Base[T] + def apply[T](x: Int, z: String="abc"): String = z +} + +object Foo2 { + def apply[T](a: Int): Base[T] = new Base[T] + def apply[T]: String = "abc" +} + +object Foo3 { + def apply[T](x: Int): Base[T] = new Base[T] + def apply[T](implicit z: String): String = z +} + +object Foo4 { + def apply[T](x: Int): Base[T] = new Base[T] + def apply[T](x: Int)(implicit z: String): Base[T] = new Base[T] +} + +object Test1 { + def test1[T] = Foo1[T](1) + def test2[T]: String = Foo1[T](1) + def test3[T]: Base[T] = Foo1[T](1) + def test4[T]: Int = Foo1[T](1) + +} + +object Test2 { + def test5[T] = Foo2[T] + def test6[T]: String = Foo2[T] + def test7[T]: Base[T] = Foo2[T] + def test8[T]: Int = Foo2[T] +} + +object Test3 { + implicit val v: String = "abc" + def test9[T]: Int = Foo3[T] + def test10[T]: Base[T] = Foo3[T] + def test11[T]: String = Foo3[T] + def test12[T] = Foo3[T] +} + +object Test4 { + def test13[T]: Int = Foo3[T] + def test14[T]: Base[T] = Foo3[T] + def test15[T]: String = Foo3[T] + def test16[T] = Foo3[T] +} + +object Test5 { + def test17[T] = Foo4[T](1) + def test18[T]: Base[T] = Foo4[T](1) + //def test19[T]: String = Foo4[T](1) // #5554 +} + + diff --git a/test/files/neg/t5554.check b/test/files/neg/t5554.check new file mode 100644 index 0000000000..8f657fd32f --- /dev/null +++ b/test/files/neg/t5554.check @@ -0,0 +1,67 @@ +t5554.scala:14: error: ambiguous reference to overloaded definition, +both method apply in object Foo1 of type (x: Int)(implicit z: String)String +and method apply in object Foo1 of type (x: Int)Base[T] +match argument types (Int) + def test1[T]: Int = Foo1[T](1) + ^ +t5554.scala:16: error: ambiguous reference to overloaded definition, +both method apply in object Foo1 of type (x: Int)(implicit z: String)String +and method apply in object Foo1 of type (x: Int)Base[T] +match argument types (Int) + def test3[T]: String = Foo1[T](1) + ^ +t5554.scala:17: error: ambiguous reference to overloaded definition, +both method apply in object Foo1 of type (x: Int)(implicit z: String)String +and method apply in object Foo1 of type (x: Int)Base[T] +match argument types (Int) + def test4[T] = Foo1[T](1) + ^ +t5554.scala:22: error: ambiguous reference to overloaded definition, +both method apply in object Foo1 of type (x: Int)(implicit z: String)String +and method apply in object Foo1 of type (x: Int)Base[T] +match argument types (Int) + def test5[T]: Int = Foo1[T](1) + ^ +t5554.scala:25: error: ambiguous reference to overloaded definition, +both method apply in object Foo1 of type (x: Int)(implicit z: String)String +and method apply in object Foo1 of type (x: Int)Base[T] +match argument types (Int) + def test8[T] = Foo1[T](1) + ^ +t5554.scala:29: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo2 of type (x: Int)Base[T] +match argument types (Int) + def test9[T]: String = Foo2[T](1) + ^ +t5554.scala:30: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo2 of type (x: Int)Base[T] +match argument types (Int) and expected result type Base[T] + def test10[T]: Base[T] = Foo2[T](1) + ^ +t5554.scala:31: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo2 of type (x: Int)Base[T] +match argument types (Int) + def test11[T] = Foo2[T](1) + ^ +t5554.scala:36: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo2 of type (x: Int)Base[T] +match argument types (Int) + def test12[T]: String = Foo2[T](1) + ^ +t5554.scala:37: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo2 of type (x: Int)Base[T] +match argument types (Int) and expected result type Base[T] + def test13[T]: Base[T] = Foo2[T](1) + ^ +t5554.scala:38: error: ambiguous reference to overloaded definition, +both method apply in object Foo2 of type (x: Int)(implicit z: String)Base[T] +and method apply in object Foo2 of type (x: Int)Base[T] +match argument types (Int) + def test14[T] = Foo2[T](1) + ^ +11 errors found diff --git a/test/files/neg/t5554.scala b/test/files/neg/t5554.scala new file mode 100644 index 0000000000..d279abea7f --- /dev/null +++ b/test/files/neg/t5554.scala @@ -0,0 +1,39 @@ +class Base[T] + +object Foo1 { + def apply[T](x: Int): Base[T] = new Base[T] + def apply[T](x: Int)(implicit z: String): String = z +} + +object Foo2 { + def apply[T](x: Int): Base[T] = new Base[T] + def apply[T](x: Int)(implicit z: String): Base[T] = new Base[T] +} + +object Test1 { + def test1[T]: Int = Foo1[T](1) + def test2[T]: Base[T] = Foo1[T](1) + def test3[T]: String = Foo1[T](1) + def test4[T] = Foo1[T](1) +} + +object Test2 { + implicit val v: String = "foo" + def test5[T]: Int = Foo1[T](1) + def test6[T]: Base[T] = Foo1[T](1) + def test7[T]: String = Foo1[T](1) + def test8[T] = Foo1[T](1) +} + +object Test3 { + def test9[T]: String = Foo2[T](1) + def test10[T]: Base[T] = Foo2[T](1) + def test11[T] = Foo2[T](1) +} + +object Test4 { + implicit val v: String = "foo" + def test12[T]: String = Foo2[T](1) + def test13[T]: Base[T] = Foo2[T](1) + def test14[T] = Foo2[T](1) +} diff --git a/test/files/neg/tailrec-2.check b/test/files/neg/tailrec-2.check index 4f763a1c8d..a918858773 100644 --- a/test/files/neg/tailrec-2.check +++ b/test/files/neg/tailrec-2.check @@ -1,4 +1,7 @@ -tailrec-2.scala:6: error: could not optimize @tailrec annotated method f: it contains a recursive call targetting a supertype +tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targetting a supertype @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) ^ -one error found +tailrec-2.scala:9: error: @tailrec annotated method contains no recursive calls + @annotation.tailrec final def f1[B >: A](mem: List[B]): List[B] = this.g(mem) + ^ +two errors found diff --git a/test/files/neg/tailrec-2.scala b/test/files/neg/tailrec-2.scala index 342cd85323..9eb3af2f07 100644 --- a/test/files/neg/tailrec-2.scala +++ b/test/files/neg/tailrec-2.scala @@ -1,9 +1,12 @@ sealed abstract class Super[+A] { def f[B >: A](mem: List[B]) : List[B] + def g(mem: List[_]) = ??? } // This one should fail, target is a supertype class Bop1[+A](val element: A) extends Super[A] { + @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) + @annotation.tailrec final def f1[B >: A](mem: List[B]): List[B] = this.g(mem) } // These succeed class Bop2[+A](val element: A) extends Super[A] { diff --git a/test/files/pos/t5546.scala b/test/files/pos/t5546.scala new file mode 100644 index 0000000000..4b0b0589b6 --- /dev/null +++ b/test/files/pos/t5546.scala @@ -0,0 +1 @@ +class A { def foo: Class[_ <: A] = getClass }
\ No newline at end of file diff --git a/test/files/run/manifests.scala b/test/files/run/manifests.scala index 1da06b8aee..6b6ea80b34 100644 --- a/test/files/run/manifests.scala +++ b/test/files/run/manifests.scala @@ -46,11 +46,20 @@ object Test def showsContravariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance - def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = (ev1 <:< ev2, ev2 <:< ev1) match { - case (true, true) => SAME - case (true, false) => SUB - case (false, true) => SUPER - case (false, false) => NONE + def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = { + // checking types as well + if ((ev1 <:< ev2) != (ev1.tpe <:< ev2.tpe)) + println("Failed! " + ((ev1, ev2))) + + if ((ev2 <:< ev1) != (ev2.tpe <:< ev1.tpe)) + println("Failed! " + ((ev2, ev1))) + + (ev1 <:< ev2, ev2 <:< ev1) match { + case (true, true) => SAME + case (true, false) => SUB + case (false, true) => SUPER + case (false, false) => NONE + } } def assertAnyRef[T: Manifest] = List( diff --git a/test/files/run/t3569.check b/test/files/run/t3569.check new file mode 100644 index 0000000000..24cee4bf00 --- /dev/null +++ b/test/files/run/t3569.check @@ -0,0 +1,17 @@ +1 +private final int Test$X.val1 +private final int Test$X.val2 +private final int Test$X.val3 +private int Test$X.lval1 +private int Test$X.lval2 +private int Test$X.lval3 +private int Test$X.var1 +private int Test$X.var2 +private int Test$X.var3 +private volatile int Test$X.bitmap$priv$0 +public int Test$X.x +public volatile int Test$X.bitmap$0 +public final int Test$Y.z1 +public final int Test$Y.z2 +public int Test$Y.x +public int Test$Y.y diff --git a/test/files/run/t3569.flags b/test/files/run/t3569.flags new file mode 100644 index 0000000000..6933d924d3 --- /dev/null +++ b/test/files/run/t3569.flags @@ -0,0 +1 @@ +-Yinline
\ No newline at end of file diff --git a/test/files/run/t3569.scala b/test/files/run/t3569.scala new file mode 100644 index 0000000000..4699aeaab3 --- /dev/null +++ b/test/files/run/t3569.scala @@ -0,0 +1,32 @@ +object Test { + final val bippy1 = 1 + final lazy val bippy2 = 2 + + lazy val lv = scala.util.Random.nextInt() + + class X(final var x: Int) { + final var var1: Int = 0 + final private var var2: Int = 0 + final private[this] var var3: Int = 0 + + final val val1: Int = 1 + final private val val2: Int = 1 + final private[this] val val3: Int = 1 + + final lazy val lval1: Int = 2 + final private lazy val lval2: Int = 2 + final private[this] lazy val lval3: Int = 2 + } + case class Y(final var x: Int, final private var y: Int, final val z1: Int, final private val z2: Int) { } + + def f = new X(0).x += 1 + def main(args: Array[String]) { + f + val s = new X(0) + s.x += 1 + println(s.x) + + (classOf[X].getDeclaredFields map ("" + _)).sorted foreach println + (classOf[Y].getDeclaredFields map ("" + _)).sorted foreach println + } +} diff --git a/test/files/run/t5545.check b/test/files/run/t5545.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t5545.check diff --git a/test/files/run/t5545.scala b/test/files/run/t5545.scala new file mode 100644 index 0000000000..7efa6d84f1 --- /dev/null +++ b/test/files/run/t5545.scala @@ -0,0 +1,27 @@ +import scala.tools.partest._ +import java.io._ + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -d " + testOutput.path + " -cp " + testOutput.path + + override def code = """ + // SI-5545 + trait F[@specialized(Int) T1, R] { + def f(v1: T1): R + def g = v1 => f(v1) + } + """.trim + + override def show(): Unit = { + // redirect err to out, for logging + val prevErr = System.err + System.setErr(System.out) + compile() + // the bug manifests at the second compilation, when the bytecode is already there + compile() + System.setErr(prevErr) + } + + override def isDebug = false // so we don't get the newSettings warning +} |