summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/t8430.check27
-rw-r--r--test/files/neg/t8430.flags1
-rw-r--r--test/files/neg/t8430.scala32
-rw-r--r--test/files/neg/t8450.check6
-rw-r--r--test/files/neg/t8450.flags1
-rw-r--r--test/files/neg/t8450.scala12
-rw-r--r--test/files/neg/t8463.check10
-rw-r--r--test/files/neg/t8463.scala38
-rw-r--r--test/files/pos/t8329.scala29
-rw-r--r--test/files/pos/t8497/A_1.scala13
-rw-r--r--test/files/pos/t8497/B_2.scala1
-rw-r--r--test/files/run/t7992.scala20
-rw-r--r--test/files/run/t7992b.scala18
13 files changed, 208 insertions, 0 deletions
diff --git a/test/files/neg/t8430.check b/test/files/neg/t8430.check
new file mode 100644
index 0000000000..7c6a73ce53
--- /dev/null
+++ b/test/files/neg/t8430.check
@@ -0,0 +1,27 @@
+t8430.scala:15: warning: match may not be exhaustive.
+It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ ^
+t8430.scala:16: warning: match may not be exhaustive.
+It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ ^
+t8430.scala:17: warning: match may not be exhaustive.
+It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ ^
+t8430.scala:18: warning: match may not be exhaustive.
+It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ ^
+t8430.scala:19: warning: match may not be exhaustive.
+It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ ^
+t8430.scala:20: warning: match may not be exhaustive.
+It would fail on the following inputs: ??, LetC, LetF, LetL(IntLit), LetP
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+6 warnings found
+one error found
diff --git a/test/files/neg/t8430.flags b/test/files/neg/t8430.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t8430.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t8430.scala b/test/files/neg/t8430.scala
new file mode 100644
index 0000000000..4166b08a0a
--- /dev/null
+++ b/test/files/neg/t8430.scala
@@ -0,0 +1,32 @@
+sealed trait CL3Literal
+case object IntLit extends CL3Literal
+case object CharLit extends CL3Literal
+case object BooleanLit extends CL3Literal
+case object UnitLit extends CL3Literal
+
+
+sealed trait Tree
+case class LetL(value: CL3Literal) extends Tree
+case object LetP extends Tree
+case object LetC extends Tree
+case object LetF extends Tree
+
+object Test {
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ (tree: Tree) => tree match {case LetL(CharLit) => ??? }
+ // After the first patch for SI-8430, we achieve stability: all of
+ // these get the same warning:
+ //
+ // ??, LetC, LetF, LetL(IntLit), LetP
+ //
+ // Before, it was non-deterministic.
+ //
+ // However, we our list of counter examples is itself non-exhaustive.
+ // We need to rework counter example generation to fix that.
+ //
+ // That work is the subject of SI-7746
+}
diff --git a/test/files/neg/t8450.check b/test/files/neg/t8450.check
new file mode 100644
index 0000000000..eeabb9730c
--- /dev/null
+++ b/test/files/neg/t8450.check
@@ -0,0 +1,6 @@
+t8450.scala:5: warning: implicit numeric widening
+ def elapsed: Foo = (System.nanoTime - 100L).foo
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+one warning found
+one error found
diff --git a/test/files/neg/t8450.flags b/test/files/neg/t8450.flags
new file mode 100644
index 0000000000..9a1332d7af
--- /dev/null
+++ b/test/files/neg/t8450.flags
@@ -0,0 +1 @@
+-Ywarn-numeric-widen -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t8450.scala b/test/files/neg/t8450.scala
new file mode 100644
index 0000000000..f20ed2bc31
--- /dev/null
+++ b/test/files/neg/t8450.scala
@@ -0,0 +1,12 @@
+trait Foo
+
+class WarnWidening {
+ implicit class FooDouble(d: Double) { def foo = new Foo {} }
+ def elapsed: Foo = (System.nanoTime - 100L).foo
+}
+
+class NoWarnWidening {
+ implicit class FooLong(l: Long) { def foo = new Foo {} }
+ implicit class FooDouble(d: Double) { def foo = new Foo {} }
+ def elapsed: Foo = (System.nanoTime - 100L).foo
+}
diff --git a/test/files/neg/t8463.check b/test/files/neg/t8463.check
new file mode 100644
index 0000000000..1a3eea2870
--- /dev/null
+++ b/test/files/neg/t8463.check
@@ -0,0 +1,10 @@
+t8463.scala:5: error: type mismatch;
+ found : Long
+ required: ?T[Long]
+Note that implicit conversions are not applicable because they are ambiguous:
+ both method longWrapper in class LowPriorityImplicits of type (x: Long)scala.runtime.RichLong
+ and method ArrowAssoc in object Predef of type [A](self: A)ArrowAssoc[A]
+ are possible conversion functions from Long to ?T[Long]
+ insertCell(Foo(5))
+ ^
+one error found
diff --git a/test/files/neg/t8463.scala b/test/files/neg/t8463.scala
new file mode 100644
index 0000000000..7c954fd834
--- /dev/null
+++ b/test/files/neg/t8463.scala
@@ -0,0 +1,38 @@
+object Test {
+ case class Foo[+T[_]](activity:T[Long])
+ type Cell[T] = T
+ def insertCell(u:Foo[Cell]) = ???
+ insertCell(Foo(5))
+}
+
+/* If SI-8230 is fixed, and `viewExists` is changed to no longer leak
+ ambiguity errors, you might expect the check file for this test to
+ change as folloes:
+
+@@ -1,18 +1,10 @@
+-t8463.scala:5: error: no type parameters for method apply: (activity:
+- --- because ---
+-argument expression's type is not compatible with formal parameter ty
++t8463.scala:5: error: type mismatch;
+ found : Long
+ required: ?T[Long]
++Note that implicit conversions are not applicable because they are am
++ both method longWrapper in class LowPriorityImplicits of type (x: Lo
++ and method ArrowAssoc in object Predef of type [A](self: A)ArrowAsso
++ are possible conversion functions from Long to ?T[Long]
+ insertCell(Foo(5))
+- ^
+-t8463.scala:5: error: type mismatch;
+- found : Long(5L)
+- required: T[Long]
+- insertCell(Foo(5))
+- ^
+-t8463.scala:5: error: type mismatch;
+- found : Test.Foo[T]
+- required: Test.Foo[Test.Cell]
+- insertCell(Foo(5))
+- ^
+-three errors found
++ ^
++one error found
+*/
diff --git a/test/files/pos/t8329.scala b/test/files/pos/t8329.scala
new file mode 100644
index 0000000000..fcd5e50b37
--- /dev/null
+++ b/test/files/pos/t8329.scala
@@ -0,0 +1,29 @@
+object Test {
+ def pf(pf: PartialFunction[Any, Unit]) = ()
+ def f1(pf: Function[Any, Unit]) = ()
+
+ class A1; class B1
+ def test1(x: String, x1: String, default: String) = pf {
+ case _ if (
+ x.isEmpty
+ && default.isEmpty // was binding to synthetic param
+ && x1.isEmpty // was binding to synthetic param
+ ) =>
+ x.isEmpty
+ default.isEmpty // was binding to synthetic param
+ x1.isEmpty // was binding to synthetic param
+ new A1; new B1
+ }
+
+ def test2(x: String, x1: String, default: String) = f1 {
+ case _ if (
+ x.isEmpty
+ && default.isEmpty
+ && x1.isEmpty
+ ) =>
+ x.isEmpty
+ default.isEmpty
+ x1.isEmpty
+ new A1; new B1
+ }
+}
diff --git a/test/files/pos/t8497/A_1.scala b/test/files/pos/t8497/A_1.scala
new file mode 100644
index 0000000000..6a76b0ee99
--- /dev/null
+++ b/test/files/pos/t8497/A_1.scala
@@ -0,0 +1,13 @@
+package p {
+ object Crash {
+ def e(s: (String @java.lang.Deprecated)): Unit = ()
+ def f(s: (String @nonStatic)): Unit = ()
+ }
+ object Ok {
+ def g(s: (String @nonStatic @static)): Unit = ()
+ def h(s: (String @static)): Unit = ()
+ }
+}
+
+class nonStatic extends scala.annotation.Annotation
+class static extends scala.annotation.StaticAnnotation
diff --git a/test/files/pos/t8497/B_2.scala b/test/files/pos/t8497/B_2.scala
new file mode 100644
index 0000000000..efe2edf2c3
--- /dev/null
+++ b/test/files/pos/t8497/B_2.scala
@@ -0,0 +1 @@
+package p { object Test { Crash } }
diff --git a/test/files/run/t7992.scala b/test/files/run/t7992.scala
new file mode 100644
index 0000000000..fde231b961
--- /dev/null
+++ b/test/files/run/t7992.scala
@@ -0,0 +1,20 @@
+class C {
+ def foo: Int = 0
+}
+
+class D extends C {
+ override def foo: Int = {
+ val f = () => {
+ class C // comment this line to fix.
+ D.super.foo // no super accessor generated here!
+ // java.lang.VerifyError: (class: D$$anonfun$1, method: apply$mcI$sp signature: ()I) Illegal use of nonvirtual function call
+ }
+ f()
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ new D().foo
+ }
+}
diff --git a/test/files/run/t7992b.scala b/test/files/run/t7992b.scala
new file mode 100644
index 0000000000..6fe1f990d5
--- /dev/null
+++ b/test/files/run/t7992b.scala
@@ -0,0 +1,18 @@
+class C {
+ def foo: Int = 0
+}
+
+class E extends C {
+ override def foo: Int = {
+ (None: Option[Int]).getOrElse {
+ class C
+ E.super.foo
+ }
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ new E().foo
+ }
+}