summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t5189_inferred.check6
-rw-r--r--test/files/neg/t5189_inferred.scala8
-rw-r--r--test/files/neg/t5340.check6
-rw-r--r--test/files/neg/t5340.scala29
-rw-r--r--test/files/neg/t5440.check5
-rw-r--r--test/files/neg/t5440.flags1
-rw-r--r--test/files/neg/t5440.scala7
-rw-r--r--test/files/neg/t5954.check16
-rw-r--r--test/files/neg/t5954.scala46
-rw-r--r--test/files/neg/t6082.check13
-rw-r--r--test/files/neg/t6082.scala2
-rw-r--r--test/files/neg/t6675-old-patmat.check4
-rw-r--r--test/files/neg/t6675-old-patmat.flags1
-rw-r--r--test/files/neg/t6675-old-patmat.scala13
-rw-r--r--test/files/neg/t6675.check4
-rw-r--r--test/files/neg/t6675.flags1
-rw-r--r--test/files/neg/t6675.scala13
-rw-r--r--test/files/neg/t6963.check2
-rw-r--r--test/files/neg/t6963.flags1
-rw-r--r--test/files/neg/t6963.scala3
-rw-r--r--test/files/pos/package-case.flags1
-rw-r--r--test/files/pos/t2130-1.flags1
-rw-r--r--test/files/pos/t2130-2.flags1
-rw-r--r--test/files/pos/t3999b.flags1
-rw-r--r--test/files/pos/t4052.flags1
-rw-r--r--test/files/pos/t6925.scala9
-rw-r--r--test/files/pos/t6925b.scala18
-rw-r--r--test/files/run/t6126.scala8
-rw-r--r--test/files/run/t6955.check1
-rw-r--r--test/files/run/t6955.scala26
30 files changed, 248 insertions, 0 deletions
diff --git a/test/files/neg/t5189_inferred.check b/test/files/neg/t5189_inferred.check
new file mode 100644
index 0000000000..9cc5dcc242
--- /dev/null
+++ b/test/files/neg/t5189_inferred.check
@@ -0,0 +1,6 @@
+t5189_inferred.scala:7: error: type mismatch;
+ found : scala.collection.immutable.Nil.type
+ required: ?A1 where type ?A1
+ f(Invariant(arr): Covariant[Any])(0) = Nil
+ ^
+one error found
diff --git a/test/files/neg/t5189_inferred.scala b/test/files/neg/t5189_inferred.scala
new file mode 100644
index 0000000000..e4e8765445
--- /dev/null
+++ b/test/files/neg/t5189_inferred.scala
@@ -0,0 +1,8 @@
+trait Covariant[+A]
+case class Invariant[A](xs: Array[A]) extends Covariant[A]
+
+class Test {
+ val arr = Array("abc")
+ def f[A](v: Covariant[A]) /*inferred!*/ = v match { case Invariant(xs) => xs }
+ f(Invariant(arr): Covariant[Any])(0) = Nil
+} \ No newline at end of file
diff --git a/test/files/neg/t5340.check b/test/files/neg/t5340.check
new file mode 100644
index 0000000000..2de19293c4
--- /dev/null
+++ b/test/files/neg/t5340.check
@@ -0,0 +1,6 @@
+t5340.scala:17: error: type mismatch;
+ found : MyApp.r.E
+ required: MyApp.s.E
+ println(b: s.E)
+ ^
+one error found
diff --git a/test/files/neg/t5340.scala b/test/files/neg/t5340.scala
new file mode 100644
index 0000000000..b283f13338
--- /dev/null
+++ b/test/files/neg/t5340.scala
@@ -0,0 +1,29 @@
+class Poly {
+ class E
+ object E {
+ implicit def conv(value: Any): E = sys.error("")
+ }
+}
+
+object MyApp {
+ val r: Poly = sys.error("")
+ val s: Poly = sys.error("")
+ val b: r.E = sys.error("")
+
+ // okay
+ s.E.conv(b): s.E
+
+ // compilation fails with error below
+ println(b: s.E)
+
+ // amb prefix: MyApp.s.type#class E MyApp.r.type#class E
+ // amb prefix: MyApp.s.type#class E MyApp.r.type#class E
+ // ../test/pending/run/t5310.scala:17: error: type mismatch;
+ // found : MyApp.r.E
+ // required: MyApp.s.E
+ // println(b: s.E)
+ // ^
+
+ // The type error is as expected, but the `amb prefix` should be logged,
+ // rather than printed to standard out.
+}
diff --git a/test/files/neg/t5440.check b/test/files/neg/t5440.check
new file mode 100644
index 0000000000..a862350a05
--- /dev/null
+++ b/test/files/neg/t5440.check
@@ -0,0 +1,5 @@
+t5440.scala:3: error: match may not be exhaustive.
+It would fail on the following inputs: (List(_), Nil), (Nil, List(_))
+ (list1, list2) match {
+ ^
+one error found
diff --git a/test/files/neg/t5440.flags b/test/files/neg/t5440.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/t5440.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t5440.scala b/test/files/neg/t5440.scala
new file mode 100644
index 0000000000..d9cf5d6252
--- /dev/null
+++ b/test/files/neg/t5440.scala
@@ -0,0 +1,7 @@
+object Test {
+ def merge(list1: List[Long], list2: List[Long]): Boolean =
+ (list1, list2) match {
+ case (hd1::_, hd2::_) => true
+ case (Nil, Nil) => true
+ }
+} \ No newline at end of file
diff --git a/test/files/neg/t5954.check b/test/files/neg/t5954.check
new file mode 100644
index 0000000000..3ca47cd430
--- /dev/null
+++ b/test/files/neg/t5954.check
@@ -0,0 +1,16 @@
+t5954.scala:36: error: implementation restriction: package object A cannot contain case class D. Instead, class D should be placed directly in package A.
+ case class D()
+ ^
+t5954.scala:35: error: implementation restriction: package object A cannot contain companion object C. Instead, object C should be placed directly in package A.
+ object C
+ ^
+t5954.scala:34: error: implementation restriction: package object A cannot contain companion trait C. Instead, trait C should be placed directly in package A.
+ trait C
+ ^
+t5954.scala:33: error: implementation restriction: package object A cannot contain companion object B. Instead, object B should be placed directly in package A.
+ object B
+ ^
+t5954.scala:32: error: implementation restriction: package object A cannot contain companion class B. Instead, class B should be placed directly in package A.
+ class B
+ ^
+5 errors found
diff --git a/test/files/neg/t5954.scala b/test/files/neg/t5954.scala
new file mode 100644
index 0000000000..9e6f5392c7
--- /dev/null
+++ b/test/files/neg/t5954.scala
@@ -0,0 +1,46 @@
+// if you ever think you've fixed the underlying reason for the implementation restrictions
+// imposed by SI-5954, then here's a test that should pass with two "succes"es
+//
+//import scala.tools.partest._
+//
+//object Test extends DirectTest {
+// def code = ???
+//
+// def problemCode = """
+// package object A {
+// class B
+// object B
+// case class C()
+// }
+// """
+//
+// def compileProblemCode() = {
+// val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+// compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(problemCode)
+// }
+//
+// def show() : Unit = {
+// for (i <- 0 until 2) {
+// compileProblemCode()
+// println(s"success ${i + 1}")
+// }
+// }
+//}
+
+package object A {
+ // these should be prevented by the implementation restriction
+ class B
+ object B
+ trait C
+ object C
+ case class D()
+ // all the rest of these should be ok
+ class E
+ object F
+ val g = "omg"
+ var h = "wtf"
+ def i = "lol"
+ type j = String
+ class K(val k : Int) extends AnyVal
+ implicit class L(val l : Int)
+}
diff --git a/test/files/neg/t6082.check b/test/files/neg/t6082.check
new file mode 100644
index 0000000000..b68de5ce08
--- /dev/null
+++ b/test/files/neg/t6082.check
@@ -0,0 +1,13 @@
+t6082.scala:1: warning: Implementation restriction: subclassing Classfile does not
+make your annotation visible at runtime. If that is what
+you want, you must write the annotation class in Java.
+class annot(notValue: String) extends annotation.ClassfileAnnotation
+ ^
+t6082.scala:2: error: classfile annotation arguments have to be supplied as named arguments
+@annot("") class C
+ ^
+t6082.scala:2: error: annotation annot is missing argument notValue
+@annot("") class C
+ ^
+one warning found
+two errors found
diff --git a/test/files/neg/t6082.scala b/test/files/neg/t6082.scala
new file mode 100644
index 0000000000..30de91a4c9
--- /dev/null
+++ b/test/files/neg/t6082.scala
@@ -0,0 +1,2 @@
+class annot(notValue: String) extends annotation.ClassfileAnnotation
+@annot("") class C \ No newline at end of file
diff --git a/test/files/neg/t6675-old-patmat.check b/test/files/neg/t6675-old-patmat.check
new file mode 100644
index 0000000000..bc3920da06
--- /dev/null
+++ b/test/files/neg/t6675-old-patmat.check
@@ -0,0 +1,4 @@
+t6675-old-patmat.scala:10: error: extractor pattern binds a single value to a Product3 of type (Int, Int, Int)
+ "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111
+ ^
+one error found
diff --git a/test/files/neg/t6675-old-patmat.flags b/test/files/neg/t6675-old-patmat.flags
new file mode 100644
index 0000000000..604de64a62
--- /dev/null
+++ b/test/files/neg/t6675-old-patmat.flags
@@ -0,0 +1 @@
+-Xlint -Xfatal-warnings -Xoldpatmat \ No newline at end of file
diff --git a/test/files/neg/t6675-old-patmat.scala b/test/files/neg/t6675-old-patmat.scala
new file mode 100644
index 0000000000..4d500b77ba
--- /dev/null
+++ b/test/files/neg/t6675-old-patmat.scala
@@ -0,0 +1,13 @@
+object X {
+ def unapply(s: String): Option[(Int,Int,Int)] = Some((1,2,3))
+}
+
+object Y {
+ def unapplySeq(s: String): Option[Seq[(Int,Int,Int)]] = Some(Seq((1,2,3)))
+}
+
+object Test {
+ "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111
+
+ "" match { case Y(b) => b } // no warning
+}
diff --git a/test/files/neg/t6675.check b/test/files/neg/t6675.check
new file mode 100644
index 0000000000..7b271de213
--- /dev/null
+++ b/test/files/neg/t6675.check
@@ -0,0 +1,4 @@
+t6675.scala:10: error: extractor pattern binds a single value to a Product3 of type (Int, Int, Int)
+ "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111
+ ^
+one error found
diff --git a/test/files/neg/t6675.flags b/test/files/neg/t6675.flags
new file mode 100644
index 0000000000..e93641e931
--- /dev/null
+++ b/test/files/neg/t6675.flags
@@ -0,0 +1 @@
+-Xlint -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t6675.scala b/test/files/neg/t6675.scala
new file mode 100644
index 0000000000..4d500b77ba
--- /dev/null
+++ b/test/files/neg/t6675.scala
@@ -0,0 +1,13 @@
+object X {
+ def unapply(s: String): Option[(Int,Int,Int)] = Some((1,2,3))
+}
+
+object Y {
+ def unapplySeq(s: String): Option[Seq[(Int,Int,Int)]] = Some(Seq((1,2,3)))
+}
+
+object Test {
+ "" match { case X(b) => b } // should warn under -Xlint. Not an error because of SI-6111
+
+ "" match { case Y(b) => b } // no warning
+}
diff --git a/test/files/neg/t6963.check b/test/files/neg/t6963.check
new file mode 100644
index 0000000000..41cb796b0b
--- /dev/null
+++ b/test/files/neg/t6963.check
@@ -0,0 +1,2 @@
+error: -Xmigration is deprecated: This setting is no longer useful and will be removed. Please remove it from your build.
+one error found
diff --git a/test/files/neg/t6963.flags b/test/files/neg/t6963.flags
new file mode 100644
index 0000000000..0b6d71496a
--- /dev/null
+++ b/test/files/neg/t6963.flags
@@ -0,0 +1 @@
+-Xmigration -deprecation -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t6963.scala b/test/files/neg/t6963.scala
new file mode 100644
index 0000000000..4da52764f5
--- /dev/null
+++ b/test/files/neg/t6963.scala
@@ -0,0 +1,3 @@
+
+object test {
+}
diff --git a/test/files/pos/package-case.flags b/test/files/pos/package-case.flags
new file mode 100644
index 0000000000..2f174c4732
--- /dev/null
+++ b/test/files/pos/package-case.flags
@@ -0,0 +1 @@
+-Ycompanions-in-pkg-objs
diff --git a/test/files/pos/t2130-1.flags b/test/files/pos/t2130-1.flags
new file mode 100644
index 0000000000..2f174c4732
--- /dev/null
+++ b/test/files/pos/t2130-1.flags
@@ -0,0 +1 @@
+-Ycompanions-in-pkg-objs
diff --git a/test/files/pos/t2130-2.flags b/test/files/pos/t2130-2.flags
new file mode 100644
index 0000000000..2f174c4732
--- /dev/null
+++ b/test/files/pos/t2130-2.flags
@@ -0,0 +1 @@
+-Ycompanions-in-pkg-objs
diff --git a/test/files/pos/t3999b.flags b/test/files/pos/t3999b.flags
new file mode 100644
index 0000000000..2f174c4732
--- /dev/null
+++ b/test/files/pos/t3999b.flags
@@ -0,0 +1 @@
+-Ycompanions-in-pkg-objs
diff --git a/test/files/pos/t4052.flags b/test/files/pos/t4052.flags
new file mode 100644
index 0000000000..2f174c4732
--- /dev/null
+++ b/test/files/pos/t4052.flags
@@ -0,0 +1 @@
+-Ycompanions-in-pkg-objs
diff --git a/test/files/pos/t6925.scala b/test/files/pos/t6925.scala
new file mode 100644
index 0000000000..862a6e9d0e
--- /dev/null
+++ b/test/files/pos/t6925.scala
@@ -0,0 +1,9 @@
+class Test {
+ def f[T](xs: Set[T]) /* no expected type to trigger inference */ =
+ xs collect { case x => x }
+
+ def g[T](xs: Set[T]): Set[T] = f[T](xs) // check that f's inferred type is Set[T]
+
+ // check that this type checks:
+ List(1).flatMap(n => Set(1).collect { case w => w })
+} \ No newline at end of file
diff --git a/test/files/pos/t6925b.scala b/test/files/pos/t6925b.scala
new file mode 100644
index 0000000000..ca25146dfc
--- /dev/null
+++ b/test/files/pos/t6925b.scala
@@ -0,0 +1,18 @@
+// code *generated* by test/scaladoc/run/SI-5933.scala
+// duplicated here because it's related to SI-6925
+
+import language.higherKinds
+
+abstract class Base[M[_, _]] {
+ def foo[A, B]: M[(A, B), Any]
+}
+
+class Derived extends Base[PartialFunction] {
+ def foo[AA, BB] /*: PartialFunction[(A, B) => Any]*/ = { case (a, b) => (a: AA, b: BB) }
+}
+
+object Test {
+ lazy val lx = { println("hello"); 3 }
+ def test1(x: Int = lx) = ???
+ def test2(x: Int = lx match { case 0 => 1; case 3 => 4 }) = ???
+} \ No newline at end of file
diff --git a/test/files/run/t6126.scala b/test/files/run/t6126.scala
new file mode 100644
index 0000000000..d552d8e695
--- /dev/null
+++ b/test/files/run/t6126.scala
@@ -0,0 +1,8 @@
+trait LogLevelType
+object Test {
+ type LogLevel = Int with LogLevelType
+ final val ErrorLevel = 1.asInstanceOf[Int with LogLevelType]
+ def main(args: Array[String]) {
+ List(ErrorLevel, ErrorLevel)
+ }
+}
diff --git a/test/files/run/t6955.check b/test/files/run/t6955.check
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/test/files/run/t6955.check
@@ -0,0 +1 @@
+2
diff --git a/test/files/run/t6955.scala b/test/files/run/t6955.scala
new file mode 100644
index 0000000000..2610acdec4
--- /dev/null
+++ b/test/files/run/t6955.scala
@@ -0,0 +1,26 @@
+import scala.tools.partest.IcodeTest
+
+class Switches {
+ type Tag = Byte
+
+ def switchBad(i: Tag): Int = i match { // notice type of i is Tag = Byte
+ case 1 => 1
+ case 2 => 2
+ case 3 => 3
+ case _ => 0
+ }
+
+ def switchOkay(i: Byte): Int = i match { // notice type of i is Byte
+ case 1 => 1
+ case 2 => 2
+ case 3 => 3
+ case _ => 0
+ }
+}
+
+object Test extends IcodeTest {
+ // ensure we get two switches out of this -- ignore the rest of the output for robustness
+ // exclude the constant we emit for the "SWITCH ..." string below (we get the icode for all the code you see in this file)
+ override def show() = println(collectIcode("").filter(x => x.indexOf("SWITCH ...") >= 0 && x.indexOf("CONSTANT(") == -1).size)
+}
+