summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/instrumented/InstrumentationTest.check4
-rw-r--r--test/files/instrumented/InstrumentationTest.scala16
-rw-r--r--test/files/neg/t3234.check2
-rw-r--r--test/files/neg/t3234.flags (renamed from test/files/pos/t3234.flags)0
-rw-r--r--test/files/neg/t3234.scala (renamed from test/files/pos/t3234.scala)0
-rw-r--r--test/files/neg/t4440.check13
-rw-r--r--test/files/neg/t4440.flags1
-rw-r--r--test/files/neg/t4440.scala19
-rw-r--r--test/files/neg/t5878.check13
-rw-r--r--test/files/neg/t5878.scala6
-rw-r--r--test/files/neg/t997.check8
-rw-r--r--test/files/neg/t997.scala2
-rw-r--r--test/files/neg/unchecked.check19
-rw-r--r--test/files/neg/unchecked.flags1
-rw-r--r--test/files/neg/unchecked.scala74
-rw-r--r--test/files/neg/unchecked2.check19
-rw-r--r--test/files/neg/unchecked2.flags1
-rw-r--r--test/files/neg/unchecked2.scala8
-rw-r--r--test/files/pos/t1439.scala2
-rw-r--r--test/files/pos/t5958.scala15
-rw-r--r--test/files/pos/t6029.scala3
-rw-r--r--test/files/pos/t6117.scala19
-rw-r--r--test/files/pos/unchecked-a.flags1
-rw-r--r--test/files/pos/unchecked-a.scala15
-rw-r--r--test/files/run/rawstrings.check1
-rw-r--r--test/files/run/rawstrings.scala3
-rw-r--r--test/files/run/reflect-resolveoverload-bynameparam.scala32
-rw-r--r--test/files/run/reflect-resolveoverload-expected.scala43
-rw-r--r--test/files/run/reflect-resolveoverload-invalid.scala43
-rw-r--r--test/files/run/reflect-resolveoverload-named.scala26
-rw-r--r--test/files/run/reflect-resolveoverload-targs.scala29
-rw-r--r--test/files/run/reflect-resolveoverload-tparm-substitute.scala77
-rw-r--r--test/files/run/reflect-resolveoverload-variadic.scala27
-rw-r--r--test/files/run/reflect-resolveoverload1.scala19
-rw-r--r--test/files/run/reflect-resolveoverload2.scala51
-rw-r--r--test/files/run/t4560.check8
-rw-r--r--test/files/run/t4560.scala65
-rw-r--r--test/files/run/t4560b.check2
-rw-r--r--test/files/run/t4560b.scala28
-rw-r--r--test/files/run/t5603.check29
-rw-r--r--test/files/run/t5603.scala42
-rw-r--r--test/files/run/t6111.check2
-rw-r--r--test/files/run/t6111.scala26
-rw-r--r--test/pending/run/t4560.scala9
-rw-r--r--test/scaladoc/run/SI-6140.check1
-rw-r--r--test/scaladoc/run/SI-6140.scala18
46 files changed, 456 insertions, 386 deletions
diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check
index 3652df270a..f0f447560a 100644
--- a/test/files/instrumented/InstrumentationTest.check
+++ b/test/files/instrumented/InstrumentationTest.check
@@ -1,4 +1,8 @@
true
Method call statistics:
+ 1 Foo1.<init>()V
+ 1 Foo1.someMethod()I
+ 1 instrumented/Foo2.<init>()V
+ 1 instrumented/Foo2.someMethod()I
1 scala/Predef$.println(Ljava/lang/Object;)V
1 scala/runtime/BoxesRunTime.boxToBoolean(Z)Ljava/lang/Boolean;
diff --git a/test/files/instrumented/InstrumentationTest.scala b/test/files/instrumented/InstrumentationTest.scala
index ec5314c624..0e53f80857 100644
--- a/test/files/instrumented/InstrumentationTest.scala
+++ b/test/files/instrumented/InstrumentationTest.scala
@@ -1,11 +1,27 @@
import scala.tools.partest.instrumented.Instrumentation._
+/** We check if classes put in empty package are properly instrumented */
+class Foo1 {
+ def someMethod = 0
+}
+
+/** We check if classes put in `instrumented` package are properly instrumented */
+package instrumented {
+ class Foo2 {
+ def someMethod = 0
+ }
+}
+
/** Tests if instrumentation itself works correctly */
object Test {
def main(args: Array[String]) {
// force predef initialization before profiling
Predef
startProfiling()
+ val foo1 = new Foo1
+ foo1.someMethod
+ val foo2 = new instrumented.Foo2
+ foo2.someMethod
// should box the boolean
println(true)
stopProfiling()
diff --git a/test/files/neg/t3234.check b/test/files/neg/t3234.check
new file mode 100644
index 0000000000..477b021e5e
--- /dev/null
+++ b/test/files/neg/t3234.check
@@ -0,0 +1,2 @@
+error: there were 1 inliner warnings; re-run with -Yinline-warnings for details
+one error found
diff --git a/test/files/pos/t3234.flags b/test/files/neg/t3234.flags
index c9cefdc4b9..c9cefdc4b9 100644
--- a/test/files/pos/t3234.flags
+++ b/test/files/neg/t3234.flags
diff --git a/test/files/pos/t3234.scala b/test/files/neg/t3234.scala
index 443d0467f0..443d0467f0 100644
--- a/test/files/pos/t3234.scala
+++ b/test/files/neg/t3234.scala
diff --git a/test/files/neg/t4440.check b/test/files/neg/t4440.check
new file mode 100644
index 0000000000..2861dc3040
--- /dev/null
+++ b/test/files/neg/t4440.check
@@ -0,0 +1,13 @@
+t4440.scala:12: error: The outer reference in this type test cannot be checked at run time.
+ case _: b.Inner => println("b")
+ ^
+t4440.scala:13: error: The outer reference in this type test cannot be checked at run time.
+ case _: a.Inner => println("a") // this is the case we want
+ ^
+t4440.scala:16: error: The outer reference in this type test cannot be checked at run time.
+ case _: a.Inner => println("a")
+ ^
+t4440.scala:17: error: The outer reference in this type test cannot be checked at run time.
+ case _: b.Inner => println("b") // this is the case we want
+ ^
+four errors found
diff --git a/test/files/neg/t4440.flags b/test/files/neg/t4440.flags
new file mode 100644
index 0000000000..779916d58f
--- /dev/null
+++ b/test/files/neg/t4440.flags
@@ -0,0 +1 @@
+-unchecked -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t4440.scala b/test/files/neg/t4440.scala
new file mode 100644
index 0000000000..383b141edd
--- /dev/null
+++ b/test/files/neg/t4440.scala
@@ -0,0 +1,19 @@
+// constructors used to drop outer fields when they were not accessed
+// however, how can you know (respecting separate compilation) that they're not accessed!?
+class Outer { final class Inner }
+
+// the matches below require Inner's outer pointer
+// until SI-4440 is fixed properly, we can't make this a run test
+// in principle, the output should be "a\nb", but without outer checks it's "b\na"
+object Test extends App {
+ val a = new Outer
+ val b = new Outer
+ (new a.Inner: Any) match {
+ case _: b.Inner => println("b")
+ case _: a.Inner => println("a") // this is the case we want
+ }
+ (new b.Inner: Any) match {
+ case _: a.Inner => println("a")
+ case _: b.Inner => println("b") // this is the case we want
+ }
+}
diff --git a/test/files/neg/t5878.check b/test/files/neg/t5878.check
new file mode 100644
index 0000000000..50dba0d272
--- /dev/null
+++ b/test/files/neg/t5878.check
@@ -0,0 +1,13 @@
+t5878.scala:1: error: value class may not unbox to itself
+case class Foo(x: Bar) extends AnyVal
+ ^
+t5878.scala:2: error: value class may not unbox to itself
+case class Bar(x: Foo) extends AnyVal
+ ^
+t5878.scala:4: error: value class may not unbox to itself
+class Foo1(val x: Bar1) extends AnyVal
+ ^
+t5878.scala:5: error: value class may not unbox to itself
+class Bar1(val x: Foo1) extends AnyVal
+ ^
+four errors found
diff --git a/test/files/neg/t5878.scala b/test/files/neg/t5878.scala
new file mode 100644
index 0000000000..b4e33627ef
--- /dev/null
+++ b/test/files/neg/t5878.scala
@@ -0,0 +1,6 @@
+case class Foo(x: Bar) extends AnyVal
+case class Bar(x: Foo) extends AnyVal
+
+class Foo1(val x: Bar1) extends AnyVal
+class Bar1(val x: Foo1) extends AnyVal
+
diff --git a/test/files/neg/t997.check b/test/files/neg/t997.check
index c9fe0de756..186095f44a 100644
--- a/test/files/neg/t997.check
+++ b/test/files/neg/t997.check
@@ -1,13 +1,7 @@
-t997.scala:7: error: wrong number of arguments for object Foo
-"x" match { case Foo(a) => Console.println(a) }
- ^
-t997.scala:7: error: not found: value a
-"x" match { case Foo(a) => Console.println(a) }
- ^
t997.scala:13: error: wrong number of arguments for object Foo
"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
^
t997.scala:13: error: not found: value a
"x" match { case Foo(a, b, c) => Console.println((a,b,c)) }
^
-four errors found
+two errors found
diff --git a/test/files/neg/t997.scala b/test/files/neg/t997.scala
index 42b46174d6..e8d10f4317 100644
--- a/test/files/neg/t997.scala
+++ b/test/files/neg/t997.scala
@@ -3,7 +3,7 @@ object Foo { def unapply(x : String) = Some(Pair(x, x)) }
object Test extends App {
-// Prints 'x'; ought not to compile (or maybe a should be the Pair?).
+// Prints '(x, x)'. Should compile as per SI-6111.
"x" match { case Foo(a) => Console.println(a) }
// Prints '(x,x)' as expected.
diff --git a/test/files/neg/unchecked.check b/test/files/neg/unchecked.check
new file mode 100644
index 0000000000..34a11db1a0
--- /dev/null
+++ b/test/files/neg/unchecked.check
@@ -0,0 +1,19 @@
+unchecked.scala:18: error: non-variable type argument String in type pattern Iterable[String] is unchecked since it is eliminated by erasure
+ case xs: Iterable[String] => xs.head // unchecked
+ ^
+unchecked.scala:22: error: non-variable type argument Any in type pattern Set[Any] is unchecked since it is eliminated by erasure
+ case xs: Set[Any] => xs.head // unchecked
+ ^
+unchecked.scala:26: error: non-variable type argument Any in type pattern Map[Any,Any] is unchecked since it is eliminated by erasure
+ case xs: Map[Any, Any] => xs.head // unchecked
+ ^
+unchecked.scala:35: error: non-variable type argument List[Nothing] in type pattern Test.Contra[List[Nothing]] is unchecked since it is eliminated by erasure
+ case xs: Contra[List[Nothing]] => xs.head // unchecked
+ ^
+unchecked.scala:50: error: non-variable type argument String in type pattern Test.Exp[String] is unchecked since it is eliminated by erasure
+ case ArrayApply(x: Exp[Array[T]], _, j: Exp[String]) => x // unchecked
+ ^
+unchecked.scala:55: error: non-variable type argument Array[T] in type pattern Test.Exp[Array[T]] is unchecked since it is eliminated by erasure
+ case ArrayApply(x: Exp[Array[T]], _, _) => x // unchecked
+ ^
+6 errors found
diff --git a/test/files/neg/unchecked.flags b/test/files/neg/unchecked.flags
new file mode 100644
index 0000000000..464cc20ea6
--- /dev/null
+++ b/test/files/neg/unchecked.flags
@@ -0,0 +1 @@
+-Xfatal-warnings -unchecked \ No newline at end of file
diff --git a/test/files/neg/unchecked.scala b/test/files/neg/unchecked.scala
new file mode 100644
index 0000000000..b50cdf9d7a
--- /dev/null
+++ b/test/files/neg/unchecked.scala
@@ -0,0 +1,74 @@
+import language.existentials
+
+object Test {
+ class Def[T]
+ class Exp[T]
+ class Contra[-T] { def head[T1 <: T] : T1 = ??? }
+ class Cov[+T] { }
+
+ case class ArrayApply[T](x: Exp[Array[T]], i: Exp[Int], j: Exp[_]) extends Def[T]
+
+ val IntArrayApply = ArrayApply[Int](new Exp[Array[Int]], new Exp[Int], new Exp[Int])
+
+ def f(x: Any) = x match {
+ case xs: Iterable[Any] => xs.head // okay
+ case _ => 0
+ }
+ def f2(x: Any) = x match {
+ case xs: Iterable[String] => xs.head // unchecked
+ case _ => 0
+ }
+ def f3(x: Any) = x match {
+ case xs: Set[Any] => xs.head // unchecked
+ case _ => 0
+ }
+ def f4(x: Any) = x match {
+ case xs: Map[Any, Any] => xs.head // unchecked
+ case _ => 0
+ }
+
+ def cf1(x: Any) = x match {
+ case xs: Contra[Nothing] => xs.head // okay
+ case _ => 0
+ }
+ def cf2(x: Any) = x match {
+ case xs: Contra[List[Nothing]] => xs.head // unchecked
+ case _ => 0
+ }
+
+ def co1(x: List[Cov[List[Int]]]) = x match {
+ case _: Seq[Cov[Seq[Any]]] => true // okay
+ case _ => false
+ }
+
+ def g[T](x: Def[T]) = x match {
+ case ArrayApply(x: Exp[Array[T]], i: Exp[Int], _) => x // okay
+ case _ => 0
+ }
+
+ def g2[T](x: Def[T]) = x match {
+ case ArrayApply(x: Exp[Array[T]], _, j: Exp[String]) => x // unchecked
+ case _ => 0
+ }
+
+ def g3[T](x: Any) = x match {
+ case ArrayApply(x: Exp[Array[T]], _, _) => x // unchecked
+ case _ => 0
+ }
+
+ def g4 = IntArrayApply match {
+ case ArrayApply(x: Exp[Array[Int]], _, _) => x // okay
+ case _ => ()
+ }
+ def g5[T](x: ArrayApply[Int]) = x match {
+ case ArrayApply(x: Exp[Array[Int]], _, _) => x // okay
+ case _ => 0
+ }
+
+ // Nope
+ //
+ // def g5 = IntArrayApply match {
+ // case ArrayApply(x: Exp[Array[String]], _, _) => x // nope
+ // case _ => ()
+ // }
+}
diff --git a/test/files/neg/unchecked2.check b/test/files/neg/unchecked2.check
new file mode 100644
index 0000000000..e37865928e
--- /dev/null
+++ b/test/files/neg/unchecked2.check
@@ -0,0 +1,19 @@
+unchecked2.scala:2: error: non-variable type argument Int in type Option[Int] is unchecked since it is eliminated by erasure
+ Some(123).isInstanceOf[Option[Int]]
+ ^
+unchecked2.scala:3: error: non-variable type argument String in type Option[String] is unchecked since it is eliminated by erasure
+ Some(123).isInstanceOf[Option[String]]
+ ^
+unchecked2.scala:4: error: non-variable type argument List[String] in type Option[List[String]] is unchecked since it is eliminated by erasure
+ Some(123).isInstanceOf[Option[List[String]]]
+ ^
+unchecked2.scala:5: error: non-variable type argument List[Int => String] in type Option[List[Int => String]] is unchecked since it is eliminated by erasure
+ Some(123).isInstanceOf[Option[List[Int => String]]]
+ ^
+unchecked2.scala:6: error: non-variable type argument (String, Double) in type Option[(String, Double)] is unchecked since it is eliminated by erasure
+ Some(123).isInstanceOf[Option[(String, Double)]]
+ ^
+unchecked2.scala:7: error: non-variable type argument String => Double in type Option[String => Double] is unchecked since it is eliminated by erasure
+ Some(123).isInstanceOf[Option[String => Double]]
+ ^
+6 errors found
diff --git a/test/files/neg/unchecked2.flags b/test/files/neg/unchecked2.flags
new file mode 100644
index 0000000000..144ddac9d3
--- /dev/null
+++ b/test/files/neg/unchecked2.flags
@@ -0,0 +1 @@
+-unchecked -Xfatal-warnings
diff --git a/test/files/neg/unchecked2.scala b/test/files/neg/unchecked2.scala
new file mode 100644
index 0000000000..a2e757e1dc
--- /dev/null
+++ b/test/files/neg/unchecked2.scala
@@ -0,0 +1,8 @@
+object Test {
+ Some(123).isInstanceOf[Option[Int]]
+ Some(123).isInstanceOf[Option[String]]
+ Some(123).isInstanceOf[Option[List[String]]]
+ Some(123).isInstanceOf[Option[List[Int => String]]]
+ Some(123).isInstanceOf[Option[(String, Double)]]
+ Some(123).isInstanceOf[Option[String => Double]]
+}
diff --git a/test/files/pos/t1439.scala b/test/files/pos/t1439.scala
index 68a7332b2a..0efcc74b65 100644
--- a/test/files/pos/t1439.scala
+++ b/test/files/pos/t1439.scala
@@ -2,7 +2,7 @@
class View[C[A]] { }
object Test {
- null match {
+ (null: Any) match {
case v: View[_] =>
}
}
diff --git a/test/files/pos/t5958.scala b/test/files/pos/t5958.scala
new file mode 100644
index 0000000000..3b910f3633
--- /dev/null
+++ b/test/files/pos/t5958.scala
@@ -0,0 +1,15 @@
+class Test {
+ def newComponent(u: Universe): u.Component = ???
+
+ class Universe { self =>
+ class Component
+
+ newComponent(this): this.Component // error, but should be fine since this is a stable reference
+ newComponent(self): self.Component // error, but should be fine since this is a stable reference
+ newComponent(self): this.Component // error, but should be fine since this is a stable reference
+ newComponent(this): self.Component // error, but should be fine since this is a stable reference
+
+ val u = this
+ newComponent(u): u.Component // ok
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t6029.scala b/test/files/pos/t6029.scala
new file mode 100644
index 0000000000..8f1bbb4ebf
--- /dev/null
+++ b/test/files/pos/t6029.scala
@@ -0,0 +1,3 @@
+final case class V[A](x: A) extends AnyVal {
+ def flatMap[B](f: A => V[B]) = if (true) this else f(x)
+}
diff --git a/test/files/pos/t6117.scala b/test/files/pos/t6117.scala
new file mode 100644
index 0000000000..6aca84f72c
--- /dev/null
+++ b/test/files/pos/t6117.scala
@@ -0,0 +1,19 @@
+package test
+
+trait ImportMe {
+ def foo(i: Int) = 1
+ def foo(s: String) = 2
+}
+
+class Test(val importMe: ImportMe) {
+ import importMe._
+ import importMe._
+
+ // A.scala:12: error: reference to foo is ambiguous;
+ // it is imported twice in the same scope by
+ // import importMe._
+ // and import importMe._
+ // println(foo(1))
+ // ^
+ println(foo(1))
+}
diff --git a/test/files/pos/unchecked-a.flags b/test/files/pos/unchecked-a.flags
new file mode 100644
index 0000000000..779916d58f
--- /dev/null
+++ b/test/files/pos/unchecked-a.flags
@@ -0,0 +1 @@
+-unchecked -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/unchecked-a.scala b/test/files/pos/unchecked-a.scala
new file mode 100644
index 0000000000..deceb91c36
--- /dev/null
+++ b/test/files/pos/unchecked-a.scala
@@ -0,0 +1,15 @@
+trait Y
+trait Z extends Y
+class X[+A <: Y]
+
+object Test {
+ def f1(x: X[_ <: Y]) = x match {
+ case _: X[Any] => // looks a little funny; `Any` is outside the bounds for `A`
+ }
+ def f2(x: X[_ <: Y]) = x match {
+ case _: X[Y] => // looks better, let's allow this (too)
+ }
+
+ // NonLocalReturnControl[_] warnings
+ def foo: Int = List(0).foldLeft(0){case _ => return 0}
+}
diff --git a/test/files/run/rawstrings.check b/test/files/run/rawstrings.check
new file mode 100644
index 0000000000..36e63594df
--- /dev/null
+++ b/test/files/run/rawstrings.check
@@ -0,0 +1 @@
+[\n\t'"$]
diff --git a/test/files/run/rawstrings.scala b/test/files/run/rawstrings.scala
new file mode 100644
index 0000000000..9df64f6625
--- /dev/null
+++ b/test/files/run/rawstrings.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ println(raw"[\n\t'${'"'}$$]")
+}
diff --git a/test/files/run/reflect-resolveoverload-bynameparam.scala b/test/files/run/reflect-resolveoverload-bynameparam.scala
deleted file mode 100644
index 7fb8c82ab8..0000000000
--- a/test/files/run/reflect-resolveoverload-bynameparam.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-
-class A
-class B extends A
-
-class C {
- def foo(x: => Int)(y: String) = x
- def foo(x: String)(y: List[_]) = x
- def foo(x: => A)(y: Array[_]) = 1
- def foo(x: A)(y: Seq[_]) = 2
- def foo(x: B)(y: Map[_, _]) = 4
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
- val c = new C
- val im = cm.reflect(c)
- val t = u.typeOf[C] member u.newTermName("foo") asTermSymbol
- val f1 = t.resolveOverloaded(posVargs = List(u.typeOf[Int])) asMethodSymbol
- val f2 = t.resolveOverloaded(posVargs = List(u.typeOf[String])) asMethodSymbol
- val f3 = t.resolveOverloaded(posVargs = List(u.typeOf[A])) asMethodSymbol
- val f4 = t.resolveOverloaded(posVargs = List(u.typeOf[B])) asMethodSymbol
- val m1 = im.reflectMethod(f1)
- val m2 = im.reflectMethod(f2)
- val m3 = im.reflectMethod(f3)
- val m4 = im.reflectMethod(f4)
- assert(m1(() => 1, null) == c.foo(1)(null))
- assert(m2("a", null) == c.foo("a")(null))
- assert(m3(new A, null) == c.foo(new A)(null))
- assert(m4(new B, null) == c.foo(new B)(null))
-}
-
diff --git a/test/files/run/reflect-resolveoverload-expected.scala b/test/files/run/reflect-resolveoverload-expected.scala
deleted file mode 100644
index 1378090309..0000000000
--- a/test/files/run/reflect-resolveoverload-expected.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-
-class A {
- override def equals(x: Any) = {
- x.isInstanceOf[A] && !x.isInstanceOf[B]
- }
-}
-class B extends A {
- override def equals(x: Any) = {
- x.isInstanceOf[B]
- }
-}
-
-class C {
- def a(x: String) = 1
- def a(x: Array[_]) = "a"
- def b(x: String) = new A
- def b(x: Array[_]) = new B
- def c(x: String) = new B
- def c(x: Array[_]) = "a"
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
- val c = new C
- val im = cm.reflect(c)
- def invoke(s: String, expectedType: u.Type, expectedResult: Any) {
- val ol = (u.typeOf[C] member u.newTermName(s)).asTermSymbol
- val methodSym = ol.resolveOverloaded(posVargs = List(u.typeOf[Null]), expected = expectedType).asMethodSymbol
- val sig = methodSym.typeSignature.asInstanceOf[u.MethodType]
- val method = im.reflectMethod(methodSym)
- assert(method(null) == expectedResult)
- }
-
- invoke("a", u.typeOf[Int], c.a(null): Int)
- invoke("a", u.typeOf[String], c.a(null): String)
- invoke("b", u.typeOf[B], c.b(null): B)
- invoke("c", u.typeOf[A], c.c(null): A)
- invoke("c", u.typeOf[A], c.c(null): A)
- invoke("c", u.typeOf[B], c.c(null): B)
- invoke("c", u.typeOf[String], c.c(null): String)
-
-}
diff --git a/test/files/run/reflect-resolveoverload-invalid.scala b/test/files/run/reflect-resolveoverload-invalid.scala
deleted file mode 100644
index 8c5dc9f94b..0000000000
--- a/test/files/run/reflect-resolveoverload-invalid.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-
-class A
-class B extends A
-
-class C {
- def a(x: Int) = 1
- def a(x: String) = 2
- def b(x: B) = 3
- def c(x: A, y: B) = 4
- def c(x: B, y: A) = 5
- def d[T](x: Int) = 6
- def d(x: String) = 7
- def e(x: A) = 8
- def e(x: =>B) = 9
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
-
- val x = new C
- val t = u.typeOf[C]
-
- val a = t member u.newTermName("a") asTermSymbol
- val b = t member u.newTermName("b") asTermSymbol
- val c = t member u.newTermName("c") asTermSymbol
- val d = t member u.newTermName("d") asTermSymbol
- val e = t member u.newTermName("e") asTermSymbol
-
- val n1 = a.resolveOverloaded(posVargs = List(u.typeOf[Long]))
- val n2 = b.resolveOverloaded(posVargs = List(u.typeOf[A]))
- val n3 = c.resolveOverloaded(posVargs = List(u.typeOf[B], u.typeOf[B]))
- val n4 = d.resolveOverloaded(targs = List(u.typeOf[Int]))
- val n5 = d.resolveOverloaded()
- val n6 = e.resolveOverloaded(posVargs = List(u.typeOf[B]))
-
- assert(n1 == u.NoSymbol)
- assert(n2 == u.NoSymbol)
- assert(n3 == u.NoSymbol)
- assert(n4 == u.NoSymbol)
- assert(n5 == u.NoSymbol)
- assert(n6 == u.NoSymbol)
-}
diff --git a/test/files/run/reflect-resolveoverload-named.scala b/test/files/run/reflect-resolveoverload-named.scala
deleted file mode 100644
index 017ec85c0d..0000000000
--- a/test/files/run/reflect-resolveoverload-named.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-
-class A {
- def foo(x: String, y: Int) = 1
- def foo(x: Int, y: String) = 2
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
- val a = new A
- val im = cm.reflect(a)
- val tpe = u.typeOf[A]
- val overloaded = tpe member u.newTermName("foo") asTermSymbol
- val ms1 =
- overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("x"), u.typeOf[String]), (u.newTermName("y"), u.typeOf[Int])))
- val ms2 =
- overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("y"), u.typeOf[Int]), (u.newTermName("x"), u.typeOf[String])))
- val ms3 =
- overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("x"), u.typeOf[Int]), (u.newTermName("y"), u.typeOf[String])))
- val ms4 =
- overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("y"), u.typeOf[String]), (u.newTermName("x"), u.typeOf[Int])))
- assert(im.reflectMethod(ms1 asMethodSymbol)("A", 1) == 1)
- assert(im.reflectMethod(ms2 asMethodSymbol)("A", 1) == 1)
- assert(im.reflectMethod(ms3 asMethodSymbol)(1, "A") == 2)
- assert(im.reflectMethod(ms4 asMethodSymbol)(1, "A") == 2)
-}
diff --git a/test/files/run/reflect-resolveoverload-targs.scala b/test/files/run/reflect-resolveoverload-targs.scala
deleted file mode 100644
index 888b2f0c15..0000000000
--- a/test/files/run/reflect-resolveoverload-targs.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-
-import reflect.runtime.{universe=>u}
-import scala.reflect.runtime.{currentMirror => cm}
-
-class C {
- def foo[T: u.TypeTag](x: String) = 1
- def foo[T: u.TypeTag, S: u.TypeTag](x: String) = 2
-}
-
-object Test extends App {
- val c = new C
- val im = cm.reflect(c)
- val foo = u.typeOf[C] member u.newTermName("foo") asTermSymbol
- val f1 = foo.resolveOverloaded(
- targs = Seq(u.typeOf[Int]),
- posVargs = Seq(u.typeOf[String])
- )
-
- val f2 = foo.resolveOverloaded(
- targs = Seq(u.typeOf[Int],
- u.typeOf[Int]), posVargs = Seq(u.typeOf[String])
- )
-
- val m1 = im.reflectMethod(f1 asMethodSymbol)
- val m2 = im.reflectMethod(f2 asMethodSymbol)
-
- assert(m1("a", u.typeTag[Int]) == c.foo[Int]("a"))
- assert(m2("a", u.typeTag[Int], u.typeTag[Int]) == c.foo[Int, Int]("a"))
-}
diff --git a/test/files/run/reflect-resolveoverload-tparm-substitute.scala b/test/files/run/reflect-resolveoverload-tparm-substitute.scala
deleted file mode 100644
index 22e7bcd40a..0000000000
--- a/test/files/run/reflect-resolveoverload-tparm-substitute.scala
+++ /dev/null
@@ -1,77 +0,0 @@
-
-class A
-class B extends A
-
-class C {
- def foo[T](x: T) = x
- def foo(x: Int) = "a"
- def foo(x: A) = x
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
- val c = new C
- val im = cm.reflect(c)
- val term = u.typeOf[C] member u.newTermName("foo") asTermSymbol
-
- val f1 = term.resolveOverloaded(
- posVargs = List(u.typeOf[Int]),
- expected = u.typeOf[String]
- )
-
- val f2 = term.resolveOverloaded(
- targs = List(u.typeOf[String]),
- posVargs = List(u.typeOf[String]),
- expected = u.typeOf[String]
- )
-
- val f3 = term.resolveOverloaded(
- posVargs = List(u.typeOf[A]),
- expected = u.typeOf[A]
- )
-
- val f4 = term.resolveOverloaded(
- targs = List(u.typeOf[A]),
- posVargs = List(u.typeOf[A]),
- expected = u.typeOf[A]
- )
-
- val f5 = term.resolveOverloaded(
- targs = List(u.typeOf[B]),
- posVargs = List(u.typeOf[B]),
- expected = u.typeOf[B]
- )
-
- val f6 = term.resolveOverloaded(
- targs = List(u.typeOf[B]),
- posVargs = List(u.typeOf[B]),
- expected = u.typeOf[A]
- )
-
- val f7 = term.resolveOverloaded(
- targs = List(u.typeOf[A]),
- posVargs = List(u.typeOf[B]),
- expected = u.typeOf[A]
- )
-
- val m1 = im.reflectMethod(f1 asMethodSymbol)
- val m2 = im.reflectMethod(f2 asMethodSymbol)
- val m3 = im.reflectMethod(f3 asMethodSymbol)
- val m4 = im.reflectMethod(f4 asMethodSymbol)
- val m5 = im.reflectMethod(f5 asMethodSymbol)
- val m6 = im.reflectMethod(f6 asMethodSymbol)
- val m7 = im.reflectMethod(f7 asMethodSymbol)
-
- val a = new A
- val b = new B
- assert(m1(2) == (c.foo(2): String))
- assert(m2("xyz") == (c.foo[String]("xyz"): String))
- assert(m3(a) == (c.foo(a): A))
- assert(m4(a) == (c.foo[A](a): A))
- assert(m5(b) == (c.foo[B](b): B))
- assert(m6(b) == (c.foo[B](b): A))
- assert(m7(b) == (c.foo[A](b): A))
-
-
-}
diff --git a/test/files/run/reflect-resolveoverload-variadic.scala b/test/files/run/reflect-resolveoverload-variadic.scala
deleted file mode 100644
index 8e2e15600f..0000000000
--- a/test/files/run/reflect-resolveoverload-variadic.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-
-class C {
- def foo(x: Int*) = 1 + x.sum
- def foo(x: String) = 2
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
- val c = new C
- val im = cm.reflect(c)
- val foo = u.typeOf[C] member u.newTermName("foo") asTermSymbol
- val f0 = foo.resolveOverloaded()
- val f1 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[Int]))
- val f2 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[Int], u.typeOf[Int]))
- val f3 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[String]))
-
- val m0 = im.reflectMethod(f0 asMethodSymbol)
- val m1 = im.reflectMethod(f1 asMethodSymbol)
- val m2 = im.reflectMethod(f2 asMethodSymbol)
- val m3 = im.reflectMethod(f3 asMethodSymbol)
-
- assert(m0(Seq()) == c.foo())
- assert(m1(Seq(1)) == c.foo(1))
- assert(m2(Seq(4, 9)) == c.foo(4, 9))
- assert(m3("abc") == c.foo("abc"))
-}
diff --git a/test/files/run/reflect-resolveoverload1.scala b/test/files/run/reflect-resolveoverload1.scala
deleted file mode 100644
index a859a0ec4e..0000000000
--- a/test/files/run/reflect-resolveoverload1.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-import scala.reflect.runtime.universe._
-import scala.reflect.runtime.{currentMirror => cm}
-
-object Test extends App {
-
- val s = "hello world"
- val m = cm.reflect(s)
- val sc = m.symbol
- val st = sc.asType
- val meth = (st member newTermName("indexOf")).asTermSymbol
- val IntType = definitions.IntClass.asType
- val indexOf = (meth resolveOverloaded(posVargs = List(IntType))).asMethodSymbol
- assert(m.reflectMethod(indexOf)('w') == 6)
- assert((m.reflectMethod(indexOf)('w') match { case x: Int => x }) == 6)
-
- val meth2 = (st member newTermName("substring")).asTermSymbol
- val substring = (meth2 resolveOverloaded(posVargs = List(IntType, IntType))).asMethodSymbol
- assert(m.reflectMethod(substring)(2, 6) == "llo ")
-}
diff --git a/test/files/run/reflect-resolveoverload2.scala b/test/files/run/reflect-resolveoverload2.scala
deleted file mode 100644
index a800a3e92c..0000000000
--- a/test/files/run/reflect-resolveoverload2.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-class A
-class B extends A
-
-class C {
- def a(x: Int) = 1
- def a(x: String) = 2
- //def b(x: => Int)(s: String) = 1
- //def b(x: => String)(a: Array[_]) = 2
- def c(x: A) = 1
- def c(x: B) = 2
- //def d(x: => A)(s: String) = 1
- //def d(x: => B)(a: Array[_]) = 2
- def e(x: A) = 1
- def e(x: B = new B) = 2
- def f(x: Int) = 1
- def f(x: String) = 2
- def f(x: Long) = 3
- def f(x: Double) = 4
-}
-
-object Test extends App {
- val cm = reflect.runtime.currentMirror
- val u = cm.universe
- val c = new C
- val im = cm.reflect(c)
- def invoke(s: String, arg: Any, argType: u.Type): Int = {
- val ol = u.typeOf[C] member u.newTermName(s) asTermSymbol
- val methodSym = ol.resolveOverloaded(posVargs = List(argType)) asMethodSymbol
- val sig = methodSym.typeSignature.asInstanceOf[u.MethodType]
- val method = im.reflectMethod(methodSym)
- if (sig.resultType.kind == "MethodType") method(arg, null).asInstanceOf[Int]
- else method(arg).asInstanceOf[Int]
- }
- assert(c.a(1) == invoke("a", 1, u.typeOf[Int]))
- assert(c.a("a") == invoke("a", "a", u.typeOf[String]))
- assert(c.a('a') == invoke("a", 'a', u.typeOf[Char]))
- assert(c.a(3: Byte) == invoke("a", 3: Byte, u.typeOf[Byte]))
- //assert(c.b(1)(null) == invoke("b", 1, u.typeOf[Int]))
- //assert(c.b("a")(null) == invoke("b", "a", u.typeOf[String]))
- assert(c.c(new A) == invoke("c", new A, u.typeOf[A]))
- assert(c.c(new B) == invoke("c", new B, u.typeOf[B]))
- //assert(c.d(new A)(null) == invoke("d", new A, u.typeOf[A]))
- //assert(c.d(new B)(null) == invoke("d", new B, u.typeOf[B]))
- assert(c.e(new A) == invoke("e", new A, u.typeOf[A]))
- assert(c.e(new B) == invoke("e", new B, u.typeOf[B]))
- assert(c.f(1: Short) == invoke("f", 1: Short, u.typeOf[Short]))
- assert(c.f(2) == invoke("f", 2, u.typeOf[Int]))
- assert(c.f(3L) == invoke("f", 3L, u.typeOf[Long]))
- assert(c.f(4f) == invoke("f", 4f, u.typeOf[Float]))
- assert(c.f(5d) == invoke("f", 5d, u.typeOf[Double]))
-}
diff --git a/test/files/run/t4560.check b/test/files/run/t4560.check
index fd3c81a4d7..f8cb0833ae 100644
--- a/test/files/run/t4560.check
+++ b/test/files/run/t4560.check
@@ -1,2 +1,6 @@
-5
-5
+'Test
+Success 1
+'Test
+Success 2
+'Test
+Success 3
diff --git a/test/files/run/t4560.scala b/test/files/run/t4560.scala
index 1392077e46..9979199067 100644
--- a/test/files/run/t4560.scala
+++ b/test/files/run/t4560.scala
@@ -1,39 +1,66 @@
-object Pimper {
- implicit def pimp(i: Int) = new {
- def test: String = i.toString
- }
-}
+// SI-4560 (and SI-4601): Reflection caches are expected in the wrong classfiles
+// with various differing constellations of self-types. This leads to runtime exceptions
+// when the reflection caches are accessed. This tests both reflection cache accesses
+// for structural type method invocations (`y.f()`) (SI-4560) and accesses to symbols which are
+// handled similarly (SI-4601)
-trait A
+// TEST 1
+// self-type is other trait
-trait B {
- self: A =>
+trait Aa
+trait Ab
- def test {
- import Pimper.pimp
+trait B {
+ self: Aa with Ab =>
- println(5.test)
+ def y = new { def f() = println("Success 1") }
+ def fail() = {
+ println('Test)
+ y.f()
}
}
+object Test1 extends Aa with Ab with B
+
+// TEST 2
+// self-type is class
+
class A2
trait B2 {
self: A2 =>
- def test {
- import Pimper.pimp
+ def y = new { def f() = println("Success 2") }
+ def fail() = {
+ println('Test)
+ y.f()
+ }
+}
+
+object Test2 extends A2 with B2
+
+// TEST 3
+// self-type is singleton type
+
+trait B3 {
+ this: Test3.type =>
- println(5.test)
+ def y = new { def f() = println("Success 3") }
+ def fail() = {
+ println('Test)
+ y.f()
}
}
-object Test extends A with B {
+object Test3 extends B3 {
+ def test { fail() }
+}
+
+object Test {
def main(args: Array[String]) {
- test
- Test2.test
+ Test1.fail()
+ Test2.fail()
+ Test3.fail()
}
}
-object Test2 extends A2 with B2
-
diff --git a/test/files/run/t4560b.check b/test/files/run/t4560b.check
new file mode 100644
index 0000000000..7ee6e19b28
--- /dev/null
+++ b/test/files/run/t4560b.check
@@ -0,0 +1,2 @@
+23
+SUCCESS
diff --git a/test/files/run/t4560b.scala b/test/files/run/t4560b.scala
new file mode 100644
index 0000000000..97fe00ce37
--- /dev/null
+++ b/test/files/run/t4560b.scala
@@ -0,0 +1,28 @@
+object Outer {
+ class Tester
+ private[Outer] trait B4 { _: Tester =>
+ protected val FREQ = 23
+ def fail() = {
+ println(FREQ)
+ }
+ }
+ object C4 extends Tester with B4
+}
+
+object Outer2 {
+ abstract class A5
+ private[Outer2] trait C5 {
+ def impl() { println("SUCCESS") }
+ }
+ trait B5 extends C5 { self: A5 =>
+ def fail() { impl() }
+ }
+ object Test5 extends A5 with B5 with C5
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ Outer.C4.fail()
+ Outer2.Test5.fail()
+ }
+}
diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check
new file mode 100644
index 0000000000..5127d3c1c7
--- /dev/null
+++ b/test/files/run/t5603.check
@@ -0,0 +1,29 @@
+[[syntax trees at end of parser]] // newSource1
+[0:241]package [0:0]<empty> {
+ [0:82]abstract trait Greeting extends [15:82][83]scala.AnyRef {
+ [15]def $init$() = [15]{
+ [15]()
+ };
+ [23:39]val name: [33:39]String;
+ [46:76]val msg = [56:76][56:72][56:71]"How are you, ".$plus([72:76]name)
+ };
+ [87:209]class C extends [94:209][151:159]Greeting {
+ [119:139]val nameElse = _;
+ [95:101]<paramaccessor> private[this] val i: [98:101]Int = _;
+ <119:139>def <init>([95]i: [98]Int) = <119:139>{
+ <119:139>val nameElse = <134:139>"Bob";
+ [94][94][94]super.<init>();
+ [94]()
+ };
+ [168:184]val name = [179:184]"avc";
+ [191:203][191:198]println([199:202]msg)
+ };
+ [215:241]object Test extends [227:241][235:238]App {
+ [227]def <init>() = [227]{
+ [227][227][227]super.<init>();
+ [227]()
+ };
+ [NoPosition]<empty>
+ }
+}
+
diff --git a/test/files/run/t5603.scala b/test/files/run/t5603.scala
new file mode 100644
index 0000000000..60dfd01fee
--- /dev/null
+++ b/test/files/run/t5603.scala
@@ -0,0 +1,42 @@
+import scala.tools.partest._
+import java.io._
+import scala.tools.nsc._
+import scala.tools.nsc.util.CommandLineParser
+import scala.tools.nsc.{Global, Settings, CompilerCommand}
+import scala.tools.nsc.reporters.ConsoleReporter
+
+object Test extends DirectTest {
+
+ override def extraSettings: String = "-usejavacp -Xprint:parser -Ystop-after:parser -d " + testOutput.path
+
+ override def code = """
+ trait Greeting {
+ val name: String
+ val msg = "How are you, "+name
+ }
+ class C(i: Int) extends {
+ val nameElse = "Bob"
+ } with Greeting {
+ val name = "avc"
+ println(msg)
+ }
+
+ object Test extends App {}
+ """.trim
+
+ override def show(): Unit = {
+ // redirect err to out, for logging
+ val prevErr = System.err
+ System.setErr(System.out)
+ compile()
+ System.setErr(prevErr)
+ }
+
+ override def newCompiler(args: String*): Global = {
+
+ val settings = new Settings()
+ settings.Xprintpos.value = true
+ val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings)
+ new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions
+ }
+}
diff --git a/test/files/run/t6111.check b/test/files/run/t6111.check
new file mode 100644
index 0000000000..7fd2e33526
--- /dev/null
+++ b/test/files/run/t6111.check
@@ -0,0 +1,2 @@
+(8,8)
+(x,x)
diff --git a/test/files/run/t6111.scala b/test/files/run/t6111.scala
new file mode 100644
index 0000000000..7cceea1d09
--- /dev/null
+++ b/test/files/run/t6111.scala
@@ -0,0 +1,26 @@
+// slightly overkill, but a good test case for implicit resolution in extractor calls,
+// along with the real fix: an extractor pattern with 1 sub-pattern should type check for all extractors
+// that return Option[T], whatever T (even if it's a tuple)
+object Foo {
+ def unapply[S, T](scrutinee: S)(implicit witness: FooHasType[S, T]): Option[T] = scrutinee match {
+ case i: Int => Some((i, i).asInstanceOf[T])
+ }
+}
+
+class FooHasType[S, T]
+object FooHasType {
+ implicit object int extends FooHasType[Int, (Int, Int)]
+}
+
+// resurrected from neg/t997
+object Foo997 { def unapply(x : String): Option[(String, String)] = Some((x, x)) }
+
+object Test extends App {
+ val x = 8
+ println(x match {
+ case Foo(p) => p // p should be a pair of Int
+ })
+
+ // Prints '(x, x)'
+ "x" match { case Foo997(a) => println(a) }
+} \ No newline at end of file
diff --git a/test/pending/run/t4560.scala b/test/pending/run/t4560.scala
deleted file mode 100644
index fe62136319..0000000000
--- a/test/pending/run/t4560.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-trait B {
- this: Test.type =>
-
- def y = new { def f() = () }
- def fail() = y.f()
-}
-object Test extends B {
- def main(args: Array[String]): Unit = fail()
-} \ No newline at end of file
diff --git a/test/scaladoc/run/SI-6140.check b/test/scaladoc/run/SI-6140.check
new file mode 100644
index 0000000000..619c56180b
--- /dev/null
+++ b/test/scaladoc/run/SI-6140.check
@@ -0,0 +1 @@
+Done.
diff --git a/test/scaladoc/run/SI-6140.scala b/test/scaladoc/run/SI-6140.scala
new file mode 100644
index 0000000000..4bb9a4dc85
--- /dev/null
+++ b/test/scaladoc/run/SI-6140.scala
@@ -0,0 +1,18 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ // This caused an infinite recursion in method inline() in CommentFactory.scala
+ override def code = """
+ /** {{ code? }} */
+ class C
+ """
+
+ // no need for special settings
+ def scaladocSettings = ""
+
+ def testModel(rootPackage: Package) = {
+ // if it doesn't hang, the test is passed
+ }
+}