summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/names-defaults-neg.check12
-rw-r--r--test/files/neg/t5044.check4
-rw-r--r--test/files/neg/t5091.check4
-rw-r--r--test/files/neg/t7623.check21
-rw-r--r--test/files/neg/t7623.flags1
-rw-r--r--test/files/neg/t7623.scala38
-rw-r--r--test/files/neg/t8463.check19
-rw-r--r--test/files/neg/t8841.check9
-rw-r--r--test/files/neg/t8841.scala15
-rw-r--r--test/files/neg/t9041.check4
-rw-r--r--test/files/neg/t9041.scala17
-rw-r--r--test/files/neg/t9093.check6
-rw-r--r--test/files/neg/t9093.scala5
13 files changed, 144 insertions, 11 deletions
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index d929cf23ec..194be72250 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -157,15 +157,15 @@ names-defaults-neg.scala:148: error: variable definition needs type because 'x'
names-defaults-neg.scala:151: error: variable definition needs type because 'x' is used as a named argument in its body.
object t6 { var x = t.f(x = 1) }
^
-names-defaults-neg.scala:151: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x.
+names-defaults-neg.scala:151: warning: failed to determine if 'x = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
object t6 { var x = t.f(x = 1) }
^
names-defaults-neg.scala:154: error: variable definition needs type because 'x' is used as a named argument in its body.
class t9 { var x = t.f(x = 1) }
^
-names-defaults-neg.scala:154: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x.
+names-defaults-neg.scala:154: warning: failed to determine if 'x = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
class t9 { var x = t.f(x = 1) }
^
names-defaults-neg.scala:168: error: variable definition needs type because 'x' is used as a named argument in its body.
@@ -180,8 +180,8 @@ names-defaults-neg.scala:174: error: reference to x is ambiguous; it is both a m
names-defaults-neg.scala:181: error: variable definition needs type because 'x' is used as a named argument in its body.
class u15 { var x = u.f(x = 1) }
^
-names-defaults-neg.scala:181: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x.
+names-defaults-neg.scala:181: warning: failed to determine if 'x = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
class u15 { var x = u.f(x = 1) }
^
names-defaults-neg.scala:184: error: reference to x is ambiguous; it is both a method parameter and a variable in scope.
diff --git a/test/files/neg/t5044.check b/test/files/neg/t5044.check
index 197da2a4e8..dc3708123f 100644
--- a/test/files/neg/t5044.check
+++ b/test/files/neg/t5044.check
@@ -1,8 +1,8 @@
t5044.scala:7: error: recursive value a needs type
val id = m(a)
^
-t5044.scala:6: warning: type-checking the invocation of method foo checks if the named argument expression 'id = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for id.
+t5044.scala:6: warning: failed to determine if 'id = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
val a = foo(id = 1)
^
one warning found
diff --git a/test/files/neg/t5091.check b/test/files/neg/t5091.check
index abd24e3145..156f695f41 100644
--- a/test/files/neg/t5091.check
+++ b/test/files/neg/t5091.check
@@ -1,8 +1,8 @@
t5091.scala:8: error: recursive value xxx needs type
val param = bar(xxx)
^
-t5091.scala:7: warning: type-checking the invocation of method foo checks if the named argument expression 'param = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for param.
+t5091.scala:7: warning: failed to determine if 'param = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
val xxx = foo(param = null)
^
one warning found
diff --git a/test/files/neg/t7623.check b/test/files/neg/t7623.check
new file mode 100644
index 0000000000..db368dd369
--- /dev/null
+++ b/test/files/neg/t7623.check
@@ -0,0 +1,21 @@
+t7623.scala:19: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def f = "" match { case X(s) => }
+ ^
+t7623.scala:21: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def g = "" match { case X(s, t) => }
+ ^
+t7623.scala:23: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def h = "" match { case X(s, t, u @ _*) => }
+ ^
+t7623.scala:9: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def f = C("") match { case C(s) => }
+ ^
+t7623.scala:11: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def g = C("") match { case C(s, t) => }
+ ^
+t7623.scala:13: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def h = C("") match { case C(s, t, u @ _*) => }
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+6 warnings found
+one error found
diff --git a/test/files/neg/t7623.flags b/test/files/neg/t7623.flags
new file mode 100644
index 0000000000..74c9e38323
--- /dev/null
+++ b/test/files/neg/t7623.flags
@@ -0,0 +1 @@
+-Xlint:stars-align -Xfatal-warnings
diff --git a/test/files/neg/t7623.scala b/test/files/neg/t7623.scala
new file mode 100644
index 0000000000..5c40f37bc1
--- /dev/null
+++ b/test/files/neg/t7623.scala
@@ -0,0 +1,38 @@
+
+
+case class C(s: String, xs: Int*)
+
+object X { def unapplySeq(a: Any): Option[(String, Seq[Int])] = Some("", List(1,2,3)) }
+
+// for case classes with varargs, avoid misaligned patterns
+trait Ctest {
+ def f = C("") match { case C(s) => }
+
+ def g = C("") match { case C(s, t) => }
+
+ def h = C("") match { case C(s, t, u @ _*) => }
+
+ def ok = C("") match { case C(s, u @ _*) => }
+}
+// for extractors that unapplySeq: Option[(Something, Seq[_])], avoid misaligned patterns
+trait Xtest {
+ def f = "" match { case X(s) => }
+
+ def g = "" match { case X(s, t) => }
+
+ def h = "" match { case X(s, t, u @ _*) => }
+
+ def ok = "" match { case X(s, u @ _*) => }
+}
+// for extractors that unapplySeq: Option[Seq[_]], anything goes
+trait Rtest {
+ val r = "(a+)".r
+
+ def f = "" match { case r(s) => }
+
+ def g = "" match { case r(s, t) => }
+
+ def h = "" match { case r(s, t, u @ _*) => }
+
+ def whatever = "" match { case r(u @ _*) => }
+}
diff --git a/test/files/neg/t8463.check b/test/files/neg/t8463.check
index 1a3eea2870..9aaacf8391 100644
--- a/test/files/neg/t8463.check
+++ b/test/files/neg/t8463.check
@@ -7,4 +7,21 @@ Note that implicit conversions are not applicable because they are ambiguous:
are possible conversion functions from Long to ?T[Long]
insertCell(Foo(5))
^
-one error found
+t8463.scala:5: error: no type parameters for method apply: (activity: T[Long])Test.Foo[T] in object Foo exist so that it can be applied to arguments (Long)
+ --- because ---
+argument expression's type is not compatible with formal parameter type;
+ found : Long
+ required: ?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))
+ ^
+four errors found
diff --git a/test/files/neg/t8841.check b/test/files/neg/t8841.check
new file mode 100644
index 0000000000..ad525dc3f8
--- /dev/null
+++ b/test/files/neg/t8841.check
@@ -0,0 +1,9 @@
+t8841.scala:13: error: recursive value c needs type
+ val ambiguousName = c.ambiguousName
+ ^
+t8841.scala:12: warning: failed to determine if 'ambiguousName = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
+ val c = new Cell(ambiguousName = Some("bla"))
+ ^
+one warning found
+one error found
diff --git a/test/files/neg/t8841.scala b/test/files/neg/t8841.scala
new file mode 100644
index 0000000000..80430d997e
--- /dev/null
+++ b/test/files/neg/t8841.scala
@@ -0,0 +1,15 @@
+class Cell(val ambiguousName: Option[String])
+
+class Test {
+ def wrap(f: Any): Nothing = ???
+
+ wrap {
+ // the namer for these two ValDefs is created when typing the argument expression
+ // of wrap. This happens to be in a silent context (tryTypedApply). Therefore, the
+ // cyclic reference will not be thrown, but transformed into a NormalTypeError by
+ // `silent`. This requires different handling in NamesDefaults.
+
+ val c = new Cell(ambiguousName = Some("bla"))
+ val ambiguousName = c.ambiguousName
+ }
+}
diff --git a/test/files/neg/t9041.check b/test/files/neg/t9041.check
new file mode 100644
index 0000000000..669e9434e0
--- /dev/null
+++ b/test/files/neg/t9041.check
@@ -0,0 +1,4 @@
+t9041.scala:11: error: could not find implicit value for parameter cellSetter: CellSetter[scala.math.BigDecimal]
+ def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) }
+ ^
+one error found
diff --git a/test/files/neg/t9041.scala b/test/files/neg/t9041.scala
new file mode 100644
index 0000000000..2bdef0d3ae
--- /dev/null
+++ b/test/files/neg/t9041.scala
@@ -0,0 +1,17 @@
+// False negative test, requires overloading in Cell.
+
+trait Cell { def setCellValue(i: Int) = () ; def setCellValue(d: Double) = () }
+
+trait Nope {
+ def f = {
+ trait CellSetter[A] {
+ def setCell(cell: Cell, data: A): Unit
+ }
+ implicit val bigDecimalCellSetter = new CellSetter[math.BigDecimal]() {
+ def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) }
+ }
+ implicit class RichCell(cell: Cell) {
+ def setCellValue[A](data: A)(implicit cellSetter: CellSetter[A]) = cellSetter.setCell(cell, data)
+ }
+ }
+}
diff --git a/test/files/neg/t9093.check b/test/files/neg/t9093.check
new file mode 100644
index 0000000000..085a433f0b
--- /dev/null
+++ b/test/files/neg/t9093.check
@@ -0,0 +1,6 @@
+t9093.scala:3: error: polymorphic expression cannot be instantiated to expected type;
+ found : [C](f: C)Null
+ required: Unit
+ val x: Unit = apply2(0)/*(0)*/
+ ^
+one error found
diff --git a/test/files/neg/t9093.scala b/test/files/neg/t9093.scala
new file mode 100644
index 0000000000..d9922ad70e
--- /dev/null
+++ b/test/files/neg/t9093.scala
@@ -0,0 +1,5 @@
+object Main {
+ def apply2[C](fa: Any)(f: C) = null
+ val x: Unit = apply2(0)/*(0)*/
+}
+