diff --git a/tests/neg-deep-subtype/i3324.scala b/tests/neg-deep-subtype/i3324.scala deleted file mode 100644 index 9b1060836430..000000000000 --- a/tests/neg-deep-subtype/i3324.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -class Foo { - def foo(x: Any): Boolean = - x.isInstanceOf[List[String]] // error -} diff --git a/tests/neg/i10247.scala b/tests/neg/i10247.scala deleted file mode 100644 index fc6268720a6d..000000000000 --- a/tests/neg/i10247.scala +++ /dev/null @@ -1,28 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -def usered = Color.Red // error: value Red is deprecated - -object DeprecatedContainer { - @deprecated("no foo", "0.1") val foo = 23 -} - -enum Day { - - @deprecated("no more Mondays!", "0.1") case Monday - -} - -enum Color { - - @deprecated("no Red", "0.1") case Red - - @deprecated("no Generic", "0.1") case Generic(rgb: Int) - - def useFoo1 = DeprecatedContainer.foo // error // check that only enum cases are avoided - def useMonday = Day.Monday // error // check that enum cases are declared in this enum - -} - -object Color { - def useFoo2 = DeprecatedContainer.foo // error // check that only enum cases are avoided -} diff --git a/tests/neg/i10930.scala b/tests/neg/i10930.scala deleted file mode 100644 index 5f8a0ca1ba76..000000000000 --- a/tests/neg/i10930.scala +++ /dev/null @@ -1,15 +0,0 @@ -//> using options -Xfatal-warnings - -import language.future -@main def Test = - type LeafElem[X] = X match - case String => Char - case Array[t] => LeafElem[t] - case Iterable[t] => LeafElem[t] - case AnyVal => X - - def leafElem[X](x: X): LeafElem[X] = x match - case x: String => x.charAt(0) // error - case x: Array[t] => leafElem(x(1)) // error - case x: Iterable[t] => leafElem(x.head) // error - case x: AnyVal => x // error diff --git a/tests/neg/i10994.scala b/tests/neg/i10994.scala deleted file mode 100644 index f5f237f22dd6..000000000000 --- a/tests/neg/i10994.scala +++ /dev/null @@ -1,4 +0,0 @@ -//> using options -Xfatal-warnings - -def foo = true match - case (b: Boolean): Boolean => () // error diff --git a/tests/neg/i11022.check b/tests/neg/i11022.check deleted file mode 100644 index 55bdb0526264..000000000000 --- a/tests/neg/i11022.check +++ /dev/null @@ -1,20 +0,0 @@ --- Error: tests/neg/i11022.scala:10:7 ---------------------------------------------------------------------------------- -10 |val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:10:19 --------------------------------------------------------------------------------- -10 |val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:11:7 ---------------------------------------------------------------------------------- -11 |val b: CaseClass = new CaseClass(42) // error: deprecated type // error: deprecated class - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:11:23 --------------------------------------------------------------------------------- -11 |val b: CaseClass = new CaseClass(42) // error: deprecated type // error: deprecated class - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass --- Error: tests/neg/i11022.scala:12:14 --------------------------------------------------------------------------------- -12 |val c: Unit = CaseClass(42).magic() // error: deprecated apply method - | ^^^^^^^^^ - | class CaseClass is deprecated: no CaseClass diff --git a/tests/neg/i11022.scala b/tests/neg/i11022.scala deleted file mode 100644 index 14bc600666f9..000000000000 --- a/tests/neg/i11022.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@deprecated("no CaseClass") -case class CaseClass(rgb: Int): - def magic(): Unit = () - -object CaseClass: - def notDeprecated(): Unit = () - -val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method -val b: CaseClass = new CaseClass(42) // error: deprecated type // error: deprecated class -val c: Unit = CaseClass(42).magic() // error: deprecated apply method -val d: Unit = CaseClass.notDeprecated() // compiles diff --git a/tests/neg/i11225b.check b/tests/neg/i11225b.check new file mode 100644 index 000000000000..12ec80515e6f --- /dev/null +++ b/tests/neg/i11225b.check @@ -0,0 +1,6 @@ +-- Error: tests/neg/i11225b.scala:6:26 --------------------------------------------------------------------------------- +6 | private var cached: A = _ // error + | ^ + | `= _` has been deprecated; use `= uninitialized` instead. + | `uninitialized` can be imported with `scala.compiletime.uninitialized`. + | This construct can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/neg/i11225b.scala b/tests/neg/i11225b.scala index a9dd1d3d2227..c2b94571e06c 100644 --- a/tests/neg/i11225b.scala +++ b/tests/neg/i11225b.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation import compiletime.uninitialized @@ -10,3 +10,4 @@ class Memo[A](x: => A): known = true cached = x cached + diff --git a/tests/neg/i11333.check b/tests/neg/i11333.check deleted file mode 100644 index ba5723488899..000000000000 --- a/tests/neg/i11333.check +++ /dev/null @@ -1,30 +0,0 @@ --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:4:19 ---------------------------------------------------------- -4 | val f1: Float = 123456789 // error - | ^^^^^^^^^ - | Widening conversion from Int to Float loses precision. - | Write `.toFloat` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:5:19 ---------------------------------------------------------- -5 | val d1: Double = 1234567890123456789L // error - | ^^^^^^^^^^^^^^^^^^^^ - | Widening conversion from Long to Double loses precision. - | Write `.toDouble` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:6:19 ---------------------------------------------------------- -6 | val f2: Float = 123456789L // error - | ^^^^^^^^^^ - | Widening conversion from Long to Float loses precision. - | Write `.toFloat` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:12:21 --------------------------------------------------------- -12 | val f1_b: Float = i1 // error - | ^^ - | Widening conversion from Int to Float loses precision. - | Write `.toFloat` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:13:21 --------------------------------------------------------- -13 | val d1_b: Double = l1 // error - | ^^ - | Widening conversion from Long to Double loses precision. - | Write `.toDouble` instead. --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:14:21 --------------------------------------------------------- -14 | val f2_b: Float = l2 // error - | ^^ - | Widening conversion from Long to Float loses precision. - | Write `.toFloat` instead. diff --git a/tests/neg/i11333.scala b/tests/neg/i11333.scala deleted file mode 100644 index bbdcceaf7e1e..000000000000 --- a/tests/neg/i11333.scala +++ /dev/null @@ -1,14 +0,0 @@ -//> using options -Xfatal-warnings - -class C: - val f1: Float = 123456789 // error - val d1: Double = 1234567890123456789L // error - val f2: Float = 123456789L // error - - inline val i1 = 123456789 - inline val l1 = 1234567890123456789L - inline val l2 = 123456789L - - val f1_b: Float = i1 // error - val d1_b: Double = l1 // error - val f2_b: Float = l2 // error diff --git a/tests/neg/i11963a.scala b/tests/neg/i11963a.scala deleted file mode 100644 index 0eb2f557624f..000000000000 --- a/tests/neg/i11963a.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options -Xfatal-warnings - -open trait Foo // error diff --git a/tests/neg/i11963b.scala b/tests/neg/i11963b.scala deleted file mode 100644 index 76097b225896..000000000000 --- a/tests/neg/i11963b.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options -Xfatal-warnings - -open abstract class Foo // error diff --git a/tests/neg/i11963c.scala b/tests/neg/i11963c.scala deleted file mode 100644 index f58f68c72368..000000000000 --- a/tests/neg/i11963c.scala +++ /dev/null @@ -1,8 +0,0 @@ -//> using options -Xfatal-warnings - -object Test { - def foo: Any = { - open class Bar // error - new Bar - } -} diff --git a/tests/neg/i12597.scala b/tests/neg/i12597.scala deleted file mode 100644 index b8859a0ae991..000000000000 --- a/tests/neg/i12597.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@main def Test = - val a: IArray[Int] = IArray(2) - val b: IArray[Any] = a - val c = b.toArray // error: deprecated - c(0) = "" diff --git a/tests/neg/i13440.scala b/tests/neg/i13440.scala deleted file mode 100644 index 443215c621ef..000000000000 --- a/tests/neg/i13440.scala +++ /dev/null @@ -1,9 +0,0 @@ -//> using options -Xfatal-warnings - -import language.`3.0-migration` - -def given = 42 // error - -case class C(enum: List[Int] = Nil) { // error - val s = s"$enum" // error -} diff --git a/tests/neg/i14705.scala b/tests/neg/i14705.scala deleted file mode 100644 index 9ffb4443416e..000000000000 --- a/tests/neg/i14705.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -val n = Nil -val b = n.head.isInstanceOf[String] // error - diff --git a/tests/neg/i15474.scala b/tests/neg/i15474.scala deleted file mode 100644 index b196d1b400ef..000000000000 --- a/tests/neg/i15474.scala +++ /dev/null @@ -1,16 +0,0 @@ -//> using options -Xfatal-warnings - -import scala.language.implicitConversions - -object Test2: - given c: Conversion[ String, Int ] = _.toInt // error - -object Prices { - opaque type Price = BigDecimal - - object Price{ - given Ordering[Price] = summon[Ordering[BigDecimal]] // error - } -} - - diff --git a/tests/neg/i15503h.scala b/tests/neg/i15503h.scala deleted file mode 100644 index cef1f6cf566f..000000000000 --- a/tests/neg/i15503h.scala +++ /dev/null @@ -1,20 +0,0 @@ -//> using options -Xfatal-warnings -Wunused:linted - -import collection.mutable.Set // error - -class A { - private val a = 1 // error - val b = 2 // OK - - private def c = 2 // error - def d(using x:Int): Int = b // ok - def e(x: Int) = 1 // OK - def f = - val x = 1 // error - def f = 2 // error - 3 - - def g(x: Int): Int = x match - case x:1 => 0 // OK - case _ => 1 -} \ No newline at end of file diff --git a/tests/neg/i17613a.scala b/tests/neg/i17613a.scala deleted file mode 100644 index d0e413098cec..000000000000 --- a/tests/neg/i17613a.scala +++ /dev/null @@ -1,23 +0,0 @@ -//> using options -Xfatal-warnings -Xlint:type-parameter-shadow - -object i17613a: - class B: - type T = Int - trait D - - def foobar[D](in: D) = in.toString // error method parameter shadows some other type - type MySeq[D] = Seq[D] // error type member's parameter shadows some other type - - class Foo[T](t: T): // error class parameter shadows some other type - def bar[T](w: T) = w.toString // error a type parameter shadows another type parameter - - // even deeply nested... - class C[M[List[_]]] // error - type E[M[List[_]]] = Int // error - def foo[N[M[List[_]]]] = ??? // error - - // ...but not between type parameters in the same list - class F[A, M[N[A]]] - type G[A, M[L[A]]] = Int - def bar[A, N[M[L[A]]]] = ??? - def main(args: Array[String]) = println("Test for type parameter shadow") diff --git a/tests/neg/i18722.scala b/tests/neg/i18722.scala deleted file mode 100644 index c68390b76201..000000000000 --- a/tests/neg/i18722.scala +++ /dev/null @@ -1,9 +0,0 @@ -//> using options -Werror -explain - -def f1: Unit = null // error -def f2: Unit = 1 // error -def f3: Unit = "a" // error -val i: Int = 1 -def f4: Unit = i // error -val u: Unit = () -def f5: Unit = u diff --git a/tests/neg/i18862-3.4.scala b/tests/neg/i18862-3.4.scala deleted file mode 100644 index a30c8c8f1a59..000000000000 --- a/tests/neg/i18862-3.4.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Werror - -import scala.language.`3.4` - -def f(x: Int*): Unit = () -def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning diff --git a/tests/neg/i18862-future-migration.scala b/tests/neg/i18862-future-migration.scala deleted file mode 100644 index ff8ba1c377c3..000000000000 --- a/tests/neg/i18862-future-migration.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Werror - -import scala.language.`future-migration` - -def f(x: Int*): Unit = () -def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning diff --git a/tests/neg/i18867-3.4.scala b/tests/neg/i18867-3.4.scala deleted file mode 100644 index c5fd2976c8b0..000000000000 --- a/tests/neg/i18867-3.4.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Werror - -import language.`3.4` - -def foo(x: Int) = x - -def test = foo _ // error diff --git a/tests/neg/i18867.scala b/tests/neg/i18867.scala deleted file mode 100644 index 722347a613f5..000000000000 --- a/tests/neg/i18867.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Werror - -def foo(x: Int) = x - -def test = foo _ // error diff --git a/tests/neg/i2333.scala b/tests/neg/i2333.scala deleted file mode 100644 index 67cddbc73f48..000000000000 --- a/tests/neg/i2333.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings -deprecation - -@deprecated("bla", "2.11.0") class Foo { - println("") - def this(x: Int) = this() -} - -object Test { - new Foo // error: deprecated - new Foo(1) // error: deprecated -} \ No newline at end of file diff --git a/tests/neg/i2673.scala b/tests/neg/i2673.scala deleted file mode 100644 index 62c787fa00fb..000000000000 --- a/tests/neg/i2673.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -package Foos - -class Foo // error -class foo diff --git a/tests/neg/i2673b.scala b/tests/neg/i2673b.scala deleted file mode 100644 index 26e09ec3297e..000000000000 --- a/tests/neg/i2673b.scala +++ /dev/null @@ -1,6 +0,0 @@ -//> using options -Xfatal-warnings - -package Foos - -class Bar // error -object bar diff --git a/tests/neg/i2673c.scala b/tests/neg/i2673c.scala deleted file mode 100644 index 575d8c25d9e0..000000000000 --- a/tests/neg/i2673c.scala +++ /dev/null @@ -1,8 +0,0 @@ -//> using options -Xfatal-warnings - -package Foos - -object Outer { - case class X() // error - object x -} diff --git a/tests/neg/i4812.check b/tests/neg/i4812.check deleted file mode 100644 index f4aee0e35dde..000000000000 --- a/tests/neg/i4812.check +++ /dev/null @@ -1,42 +0,0 @@ --- [E092] Pattern Match Error: tests/neg/i4812.scala:8:11 -------------------------------------------------------------- -8 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:18:11 ------------------------------------------------------------- -18 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:28:11 ------------------------------------------------------------- -28 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:38:11 ------------------------------------------------------------- -38 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:50:13 ------------------------------------------------------------- -50 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:60:11 ------------------------------------------------------------- -60 | case prev: A => // error: the type test for A cannot be checked at runtime - | ^ - | the type test for A cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i4812.scala:96:11 ------------------------------------------------------------- -96 | case x: B => // error: the type test for B cannot be checked at runtime - | ^ - | the type test for B cannot be checked at runtime because it's a local class - | - | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i4936b.scala b/tests/neg/i4936b.scala deleted file mode 100644 index 58c240e92309..000000000000 --- a/tests/neg/i4936b.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options -Xfatal-warnings - -final object Foo // error diff --git a/tests/neg/i5013.scala b/tests/neg/i5013.scala deleted file mode 100644 index adf09e2cf3be..000000000000 --- a/tests/neg/i5013.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -class Foo { - - def foo1: Unit = 2 // error: A pure expression does nothing in statement position - - def foo2: Unit = { - 3 // error: A pure expression does nothing in statement position - 4 // error: A pure expression does nothing in statement position - } -} diff --git a/tests/neg/i6190b.scala b/tests/neg/i6190b.scala deleted file mode 100644 index 42270c1a984c..000000000000 --- a/tests/neg/i6190b.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -case class Rule(name: String) - -def foo = List("1", "2").map(Rule) // error diff --git a/tests/neg/i7821b.scala b/tests/neg/i7821b.scala deleted file mode 100644 index f82a38d259e1..000000000000 --- a/tests/neg/i7821b.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings - -object Test { - - { def f(x: Int, y: Int): Int = f(x, y) } // error - { def f(x: Int, y: Int): Int = { f(x, y) } } // error - { def f(x: Int, y: Int): Int = f(y, x) } // error - { def f(x: Int, y: Int): Int = f(x, x) } // error - { def f(x: Int, y: Int): Int = f(1, 1) } // error - { def f(x: Int, y: Int): Int = { val a = 3; f(a, 1) } } // error - { def f(x: Int): Int = f(1) } // error - -} diff --git a/tests/neg/i8781b.scala b/tests/neg/i8781b.scala deleted file mode 100644 index 7c9b074e1be7..000000000000 --- a/tests/neg/i8781b.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Xfatal-warnings - -object Test: - - println((3: Boolean | Int).isInstanceOf[Boolean]) - - println(3.isInstanceOf[Boolean]) // error diff --git a/tests/neg/i9166.scala b/tests/neg/i9166.scala deleted file mode 100644 index b9644bf56f71..000000000000 --- a/tests/neg/i9166.scala +++ /dev/null @@ -1,7 +0,0 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns -object UnitTest extends App { - def foo(m: Unit) = m match { - case runtime.BoxedUnit.UNIT => println("ok") // error - } - foo(()) -} diff --git a/tests/neg/i9266.scala b/tests/neg/i9266.scala deleted file mode 100644 index e6f8db7417c7..000000000000 --- a/tests/neg/i9266.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -import language.`future-migration` - -def test = { implicit x: Int => x + x } // error diff --git a/tests/neg/i9751.scala b/tests/neg/i9751.scala deleted file mode 100644 index 618d237e0cd4..000000000000 --- a/tests/neg/i9751.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Xfatal-warnings - -def f(): Unit = { - () // error - () -} - -inline def g(): Unit = { - () // error - () -} diff --git a/tests/neg/implicit-conversions-old.scala b/tests/neg/implicit-conversions-old.scala deleted file mode 100644 index 0a7b75766bbf..000000000000 --- a/tests/neg/implicit-conversions-old.scala +++ /dev/null @@ -1,25 +0,0 @@ -//> using options -Xfatal-warnings -feature - -class A -class B - -object A { - - implicit def a2b(x: A): B = ??? // error under -Xfatal-warnings -feature - - implicit def b2a(x: B): A = ??? // error under -Xfatal-warnings -feature -} - -class C - -object D { - implicit def a2c(x: A): C = ??? // error under -Xfatal-warnings -feature -} - -object Test { - import D.* - - val x1: A = new B - val x2: B = new A // ok, since it's an old-style comversion - val x3: C = new A // ok, since it's an old-style comversion -} \ No newline at end of file diff --git a/tests/warn/i10247.scala b/tests/warn/i10247.scala new file mode 100644 index 000000000000..aa344362cac2 --- /dev/null +++ b/tests/warn/i10247.scala @@ -0,0 +1,28 @@ +//> using options -deprecation + +def usered = Color.Red // warn: value Red is deprecated + +object DeprecatedContainer { + @deprecated("no foo", "0.1") val foo = 23 +} + +enum Day { + + @deprecated("no more Mondays!", "0.1") case Monday + +} + +enum Color { + + @deprecated("no Red", "0.1") case Red + + @deprecated("no Generic", "0.1") case Generic(rgb: Int) + + def useFoo1 = DeprecatedContainer.foo // warn // check that only enum cases are avoided + def useMonday = Day.Monday // warn // check that enum cases are declared in this enum + +} + +object Color { + def useFoo2 = DeprecatedContainer.foo // warn // check that only enum cases are avoided +} \ No newline at end of file diff --git a/tests/warn/i10930.scala b/tests/warn/i10930.scala new file mode 100644 index 000000000000..5d88235d0951 --- /dev/null +++ b/tests/warn/i10930.scala @@ -0,0 +1,15 @@ + + +import language.future +@main def Test = + type LeafElem[X] = X match + case String => Char + case Array[t] => LeafElem[t] + case Iterable[t] => LeafElem[t] + case AnyVal => X + + def leafElem[X](x: X): LeafElem[X] = x match + case x: String => x.charAt(0) // warn + case x: Array[t] => leafElem(x(1)) // warn + case x: Iterable[t] => leafElem(x.head) // warn + case x: AnyVal => x // warn \ No newline at end of file diff --git a/tests/warn/i10994.scala b/tests/warn/i10994.scala new file mode 100644 index 000000000000..74fe3bba3778 --- /dev/null +++ b/tests/warn/i10994.scala @@ -0,0 +1,5 @@ + + +def foo = true match + case (b: Boolean): Boolean => () // warn + diff --git a/tests/warn/i11022.check b/tests/warn/i11022.check new file mode 100644 index 000000000000..4257bb64652c --- /dev/null +++ b/tests/warn/i11022.check @@ -0,0 +1,20 @@ +-- Deprecation Warning: tests/warn/i11022.scala:10:7 ------------------------------------------------------------------- +10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:10:19 ------------------------------------------------------------------ +10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:11:7 ------------------------------------------------------------------- +11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:11:23 ------------------------------------------------------------------ +11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass +-- Deprecation Warning: tests/warn/i11022.scala:12:14 ------------------------------------------------------------------ +12 |val c: Unit = CaseClass(42).magic() // warn: deprecated apply method + | ^^^^^^^^^ + | class CaseClass is deprecated: no CaseClass diff --git a/tests/warn/i11022.scala b/tests/warn/i11022.scala new file mode 100644 index 000000000000..8e2de9d8f519 --- /dev/null +++ b/tests/warn/i11022.scala @@ -0,0 +1,13 @@ +//> using options -deprecation + +@deprecated("no CaseClass") +case class CaseClass(rgb: Int): + def magic(): Unit = () + +object CaseClass: + def notDeprecated(): Unit = () + +val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method +val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class +val c: Unit = CaseClass(42).magic() // warn: deprecated apply method +val d: Unit = CaseClass.notDeprecated() // compiles \ No newline at end of file diff --git a/tests/neg/i11097.scala b/tests/warn/i11097.scala similarity index 89% rename from tests/neg/i11097.scala rename to tests/warn/i11097.scala index 149fe89249c8..51c02a627a15 100644 --- a/tests/neg/i11097.scala +++ b/tests/warn/i11097.scala @@ -1,12 +1,12 @@ -//> using options -Xfatal-warnings + @main def test: Unit = { class C { type T1; type T2 } def pmatch(s: C): s.T2 = s match { - case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // error + case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // warn (3: p.T1): p.T2 - case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // error + case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // warn ("this branch should be matched": p.T1): p.T2 } diff --git a/tests/warn/i11333.check b/tests/warn/i11333.check new file mode 100644 index 000000000000..df22502cc649 --- /dev/null +++ b/tests/warn/i11333.check @@ -0,0 +1,30 @@ +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:4:19 ------------------------------------------------------- +4 | val f1: Float = 123456789 // warn + | ^^^^^^^^^ + | Widening conversion from Int to Float loses precision. + | Write `.toFloat` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:5:19 ------------------------------------------------------- +5 | val d1: Double = 1234567890123456789L // warn + | ^^^^^^^^^^^^^^^^^^^^ + | Widening conversion from Long to Double loses precision. + | Write `.toDouble` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:6:19 ------------------------------------------------------- +6 | val f2: Float = 123456789L // warn + | ^^^^^^^^^^ + | Widening conversion from Long to Float loses precision. + | Write `.toFloat` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:12:21 ------------------------------------------------------ +12 | val f1_b: Float = i1 // warn + | ^^ + | Widening conversion from Int to Float loses precision. + | Write `.toFloat` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:13:21 ------------------------------------------------------ +13 | val d1_b: Double = l1 // warn + | ^^ + | Widening conversion from Long to Double loses precision. + | Write `.toDouble` instead. +-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:14:21 ------------------------------------------------------ +14 | val f2_b: Float = l2 // warn + | ^^ + | Widening conversion from Long to Float loses precision. + | Write `.toFloat` instead. diff --git a/tests/warn/i11333.scala b/tests/warn/i11333.scala new file mode 100644 index 000000000000..210916b30aaf --- /dev/null +++ b/tests/warn/i11333.scala @@ -0,0 +1,14 @@ + + +class C: + val f1: Float = 123456789 // warn + val d1: Double = 1234567890123456789L // warn + val f2: Float = 123456789L // warn + + inline val i1 = 123456789 + inline val l1 = 1234567890123456789L + inline val l2 = 123456789L + + val f1_b: Float = i1 // warn + val d1_b: Double = l1 // warn + val f2_b: Float = l2 // warn \ No newline at end of file diff --git a/tests/neg/i11344.scala b/tests/warn/i11344.scala similarity index 73% rename from tests/neg/i11344.scala rename to tests/warn/i11344.scala index 0602fe14a995..f8af81369162 100644 --- a/tests/neg/i11344.scala +++ b/tests/warn/i11344.scala @@ -1,8 +1,9 @@ -//> using options -Xfatal-warnings -deprecation +//> using options -deprecation trait Pet(val name: String, rest: Int): def f(suffix: String) = s"$name$suffix$rest" -class Birdie(override val name: String) extends Pet("huh", 1) // error +class Birdie(override val name: String) extends Pet("huh", 1) // warn + diff --git a/tests/warn/i11963a.scala b/tests/warn/i11963a.scala new file mode 100644 index 000000000000..b6743d92a4ac --- /dev/null +++ b/tests/warn/i11963a.scala @@ -0,0 +1,4 @@ + + +open trait Foo // warn + diff --git a/tests/warn/i11963b.scala b/tests/warn/i11963b.scala new file mode 100644 index 000000000000..5868e6979214 --- /dev/null +++ b/tests/warn/i11963b.scala @@ -0,0 +1,4 @@ + + +open abstract class Foo // warn + diff --git a/tests/warn/i11963c.scala b/tests/warn/i11963c.scala new file mode 100644 index 000000000000..245b436ee1e9 --- /dev/null +++ b/tests/warn/i11963c.scala @@ -0,0 +1,8 @@ + + +object Test { + def foo: Any = { + open class Bar // warn + new Bar + } +} diff --git a/tests/neg/i12253.check b/tests/warn/i12253.check similarity index 69% rename from tests/neg/i12253.check rename to tests/warn/i12253.check index 75a698249dee..e33a6214a438 100644 --- a/tests/neg/i12253.check +++ b/tests/warn/i12253.check @@ -1,11 +1,11 @@ --- [E092] Pattern Match Error: tests/neg/i12253.scala:13:10 ------------------------------------------------------------ -13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // error // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/i12253.scala:13:10 ----------------------------------------------- +13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // warn // warn | ^ |the type test for extractors.q2.reflect.Term cannot be checked at runtime because it refers to an abstract type member or type parameter | | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Error: tests/neg/i12253.scala:13:38 ------------------------------------------------------------ -13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // error // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/i12253.scala:13:38 ----------------------------------------------- +13 | case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // warn // warn | ^ |the type test for q1.reflect.Select cannot be checked at runtime because it refers to an abstract type member or type parameter | diff --git a/tests/neg/i12253.scala b/tests/warn/i12253.scala similarity index 93% rename from tests/neg/i12253.scala rename to tests/warn/i12253.scala index 540ff8ef6d5b..d632de7c43f4 100644 --- a/tests/neg/i12253.scala +++ b/tests/warn/i12253.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.quoted.{given, *} import deriving.*, compiletime.* @@ -10,7 +10,7 @@ object MacroUtils: import quotes.reflect.* val extractors = new Extractors code.asTerm match - case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // error // error + case extractors.InlinedLambda(_, Select(_, name)) => Expr(name) // warn // warn case t => report.throwError(s"Illegal argument to extractor: ${code.show}, in tasty: $t") class Extractors(using val q2: Quotes): @@ -27,4 +27,5 @@ object MacroUtils: end Extractors end MacroUtils -// nopos-error + +// nopos-warn deprecation \ No newline at end of file diff --git a/tests/warn/i12597.scala b/tests/warn/i12597.scala new file mode 100644 index 000000000000..57546a69b173 --- /dev/null +++ b/tests/warn/i12597.scala @@ -0,0 +1,8 @@ +//> using options -deprecation + +@main def Test = + val a: IArray[Int] = IArray(2) + val b: IArray[Any] = a + val c = b.toArray // warn: deprecated + c(0) = "" + diff --git a/tests/neg/i13011.scala b/tests/warn/i13011.scala similarity index 60% rename from tests/neg/i13011.scala rename to tests/warn/i13011.scala index c0541aeb7f8e..0675ec936d0c 100644 --- a/tests/neg/i13011.scala +++ b/tests/warn/i13011.scala @@ -1,23 +1,23 @@ -//> using options -Xfatal-warnings + class i13011 { - lazy implicit val simple1: String = simple1 // error + lazy implicit val simple1: String = simple1 // warn def f: Unit = { - lazy val simple2: String = simple2 // error + lazy val simple2: String = simple2 // warn } - lazy val simple3: String = if true then this.simple3 else "a" // error + lazy val simple3: String = if true then this.simple3 else "a" // warn def firstDigitIsEven(n: Int): Boolean = if n % 10 == n then n % 2 == 0 else firstDigitIsEven(n / 10) lazy val simple4: String = if firstDigitIsEven(22) then this.simple4 else "a" // ok - lazy val simple5: String = identity(this.simple5) // error + lazy val simple5: String = identity(this.simple5) // warn - lazy val simple6: String = { // error + lazy val simple6: String = { // warn this.simple6 "aa" } lazy val simple7: Function0[Any] = () => this.simple7 // Ok -} +} \ No newline at end of file diff --git a/tests/neg/i13440.check b/tests/warn/i13440.check similarity index 71% rename from tests/neg/i13440.check rename to tests/warn/i13440.check index 277d3dce0bf0..4ed3dbb09f7b 100644 --- a/tests/neg/i13440.check +++ b/tests/warn/i13440.check @@ -1,15 +1,15 @@ --- Error: tests/neg/i13440.scala:5:4 ----------------------------------------------------------------------------------- -5 |def given = 42 // error +-- Migration Warning: tests/warn/i13440.scala:5:4 ---------------------------------------------------------------------- +5 |def given = 42 // warn | ^ | given is now a keyword, write `given` instead of given to keep it as an identifier | This can be rewritten automatically under -rewrite -source 3.0-migration. --- Error: tests/neg/i13440.scala:7:13 ---------------------------------------------------------------------------------- -7 |case class C(enum: List[Int] = Nil) { // error +-- Migration Warning: tests/warn/i13440.scala:7:13 --------------------------------------------------------------------- +7 |case class C(enum: List[Int] = Nil) { // warn | ^ | enum is now a keyword, write `enum` instead of enum to keep it as an identifier | This can be rewritten automatically under -rewrite -source 3.0-migration. --- Error: tests/neg/i13440.scala:8:11 ---------------------------------------------------------------------------------- -8 | val s = s"$enum" // error +-- Migration Warning: tests/warn/i13440.scala:8:11 --------------------------------------------------------------------- +8 | val s = s"$enum" // warn | ^ | enum is now a keyword, write `enum` instead of enum to keep it as an identifier | This can be rewritten automatically under -rewrite -source 3.0-migration. diff --git a/tests/warn/i13440.scala b/tests/warn/i13440.scala new file mode 100644 index 000000000000..4f1337391d61 --- /dev/null +++ b/tests/warn/i13440.scala @@ -0,0 +1,9 @@ + + +import language.`3.0-migration` + +def given = 42 // warn + +case class C(enum: List[Int] = Nil) { // warn + val s = s"$enum" // warn +} \ No newline at end of file diff --git a/tests/neg/i13542.scala b/tests/warn/i13542.scala similarity index 75% rename from tests/neg/i13542.scala rename to tests/warn/i13542.scala index c0feb88b556d..f573aafadc7a 100644 --- a/tests/neg/i13542.scala +++ b/tests/warn/i13542.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.language.implicitConversions @@ -16,12 +16,12 @@ def lazyIdentity[T](x: => T): T = x def repIdentity[T](x: T*): T = x(0) val x1 = - implicit def barToFoo(bar: Bar): Foo = bar.toFoo // error: infinite loop in function body + implicit def barToFoo(bar: Bar): Foo = bar.toFoo // warn: infinite loop in function body val foo: Foo = Bar(1) val x2 = implicit def barToFoo2(bar: Bar): Foo = - identity(bar.toFoo) // error + identity(bar.toFoo) // warn val foo: Foo = Bar(1) val x3 = @@ -31,12 +31,12 @@ val x3 = val x4 = implicit def barToFoo4(bar: Bar): Foo = - repIdentity(bar.toFoo) // error + repIdentity(bar.toFoo) // warn val foo: Foo = Bar(1) val x5 = implicit def barToFoo4(bar: Bar): Foo = - val y = bar.toFoo // error + val y = bar.toFoo // warn y val foo: Foo = Bar(1) @@ -44,9 +44,4 @@ val x6 = implicit def barToFoo4(bar: Bar): Foo = lazy val y = bar.toFoo if false then y else ??? - val foo: Foo = Bar(1) - - - - - + val foo: Foo = Bar(1) \ No newline at end of file diff --git a/tests/warn/i14705.scala b/tests/warn/i14705.scala new file mode 100644 index 000000000000..a6c56ed8b927 --- /dev/null +++ b/tests/warn/i14705.scala @@ -0,0 +1,6 @@ + + +val n = Nil +val b = n.head.isInstanceOf[String] // warn + + diff --git a/tests/neg/i14721.scala b/tests/warn/i14721.scala similarity index 72% rename from tests/neg/i14721.scala rename to tests/warn/i14721.scala index 46786f04558b..9739bab5801b 100644 --- a/tests/neg/i14721.scala +++ b/tests/warn/i14721.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class C: def op: Unit = println("op") @@ -6,4 +6,5 @@ class C: def test: Unit = try op catch case _: NullPointerException => - handler // error + handler // warn + diff --git a/tests/warn/i15474.scala b/tests/warn/i15474.scala new file mode 100644 index 000000000000..d7c41130a1bb --- /dev/null +++ b/tests/warn/i15474.scala @@ -0,0 +1,16 @@ + + +import scala.language.implicitConversions + +object Test2: + given c: Conversion[ String, Int ] = _.toInt // warn + +object Prices { + opaque type Price = BigDecimal + + object Price{ + given Ordering[Price] = summon[Ordering[BigDecimal]] // warn + } +} + + diff --git a/tests/neg/i15479.scala b/tests/warn/i15479.scala similarity index 68% rename from tests/neg/i15479.scala rename to tests/warn/i15479.scala index d4f306a12368..b69296ae23e4 100644 --- a/tests/neg/i15479.scala +++ b/tests/warn/i15479.scala @@ -1,4 +1,4 @@ -//> using options -source future -deprecation -Xfatal-warnings +//> using options -source future -deprecation package deptest { @deprecated("Not used any more", since="7") @@ -8,11 +8,11 @@ package deptest { } package depuser { - import deptest.DeprecatedThing.* // error + import deptest.DeprecatedThing.* // warn object DepUser { def main(args: Array[String]): Unit = println { oldValue } } -} \ No newline at end of file +} diff --git a/tests/neg/i15503a.scala b/tests/warn/i15503a.scala similarity index 85% rename from tests/neg/i15503a.scala rename to tests/warn/i15503a.scala index b5f17a1e2f52..df8691c21a13 100644 --- a/tests/neg/i15503a.scala +++ b/tests/warn/i15503a.scala @@ -1,13 +1,13 @@ -//> using options -Xfatal-warnings -Wunused:imports +//> using options -Wunused:imports object FooUnused: - import collection.mutable.Set // error - import collection.mutable.{Map => MutMap} // error - import collection.mutable._ // error + import collection.mutable.Set // warn + import collection.mutable.{Map => MutMap} // warn + import collection.mutable._ // warn object FooWildcardUnused: - import collection.mutable._ // error + import collection.mutable._ // warn object Foo: import collection.mutable.Set // OK @@ -22,7 +22,7 @@ object FooWildcard: val bar = Set() // OK object FooNestedUnused: - import collection.mutable.Set // error + import collection.mutable.Set // warn object Nested: def hello = 1 @@ -32,11 +32,11 @@ object FooNested: def hello = Set() object FooGivenUnused: - import SomeGivenImports.given // error + import SomeGivenImports.given // warn object FooGiven: import SomeGivenImports.given // OK - import SomeGivenImports._ // error + import SomeGivenImports._ // warn val foo = summon[Int] @@ -52,7 +52,7 @@ object FooTypeName: import collection.mutable.Map // OK import collection.mutable.Seq // OK import collection.mutable.ArrayBuilder // OK - import collection.mutable.ListBuffer // error + import collection.mutable.ListBuffer // warn def checkImplicit[A](using Set[A]) = () def checkParamType[B](a: Map[B,B]): Seq[B] = ??? @@ -64,12 +64,12 @@ object FooTypeName: object InlineChecks: object InlineFoo: import collection.mutable.Set // ok - import collection.mutable.Map // error + import collection.mutable.Map // warn inline def getSet = Set(1) object InlinedBar: import collection.mutable.Set // ok - import collection.mutable.Map // error + import collection.mutable.Map // warn val a = InlineFoo.getSet object MacroChecks: @@ -80,7 +80,7 @@ object MacroChecks: object InnerMostCheck: - import collection.mutable.* // error + import collection.mutable.* // warn def check = import collection.mutable.* //OK val a = Set(1) @@ -88,7 +88,7 @@ object InnerMostCheck: object IgnoreExclusion: import collection.mutable.{Set => _} // OK import collection.mutable.{Map => _} // OK - import collection.mutable.{ListBuffer} // error + import collection.mutable.{ListBuffer} // warn def check = val a = Set(1) val b = Map(1 -> 2) @@ -106,7 +106,7 @@ package testsamepackageimport: } package p { - import p._ // error + import p._ // warn package q { class U { def f = new C @@ -120,7 +120,7 @@ package testpackageimport: val x: Int = 0 package b: - import a._ // error + import a._ // warn /* END : Check on packages*/ @@ -149,7 +149,7 @@ object GivenImportOrderAtoB: object A { implicit val x: X = new X } object B { implicit val y: Y = new Y } class C { - import A._ // error + import A._ // warn import B._ // OK def t = implicitly[X] } @@ -161,7 +161,7 @@ object GivenImportOrderBtoA: object B { implicit val y: Y = new Y } class C { import B._ // OK - import A._ // error + import A._ // warn def t = implicitly[X] } /* END : tests on given import order */ @@ -174,19 +174,19 @@ object Scala2ImplicitsGiven: import A.given // OK val b = summon[Int] object C: - import A.given // error + import A.given // warn val b = 1 object D: import A._ // OK val b = summon[Int] object E: - import A._ // error + import A._ // warn val b = 1 object F: import A.x // OK val b = summon[Int] object G: - import A.x // error + import A.x // warn val b = 1 // ------------------------------------- @@ -226,7 +226,7 @@ package testOnOverloadedMethodsImports: package b: object D extends a.C package c: - import b.D.foo // error + import b.D.foo // warn package d: import b.D.foo // OK def bar = foo((??? : a.A)) @@ -242,13 +242,13 @@ package testOnOverloadedMethodsImports: package foo.testing.rename.imports: import collection.mutable.{Set => MutSet1} // OK import collection.mutable.{Set => MutSet2} // OK - import collection.mutable.{Set => MutSet3} // error + import collection.mutable.{Set => MutSet3} // warn type A[X] = MutSet1[X] val a = MutSet2(1) //------------------------------------- package foo.testing.imports.precedence: - import scala.collection.immutable.{BitSet => _, _} // error + import scala.collection.immutable.{BitSet => _, _} // warn import scala.collection.immutable.BitSet // OK def t = BitSet.empty diff --git a/tests/neg/i15503b.scala b/tests/warn/i15503b.scala similarity index 71% rename from tests/neg/i15503b.scala rename to tests/warn/i15503b.scala index 4dc10e12606d..7ab86026ff00 100644 --- a/tests/neg/i15503b.scala +++ b/tests/warn/i15503b.scala @@ -1,17 +1,17 @@ -//> using options -Xfatal-warnings -Wunused:locals +//> using options -Wunused:locals val a = 1 // OK var cs = 3 // OK val b = // OK - var e3 = 2 // error - val e1 = 1 // error - def e2 = 2 // error + var e3 = 2 // warn + val e1 = 1 // warn + def e2 = 2 // warn 1 val c = // OK - var e1 = 1 // error not set + var e1 = 1 // warn not set def e2 = e1 // OK val e3 = e2 // OK e3 @@ -26,14 +26,14 @@ val g = // OK def d = 1 // OK def e = // OK - val e1 = 1 // error - def e2 = 2 // error - var e3 = 4 // error + val e1 = 1 // warn + def e2 = 2 // warn + var e3 = 4 // warn 1 def f = // OK val f1 = 1 // OK - var f2 = f1 // error not set + var f2 = f1 // warn not set def f3 = f2 // OK f3 @@ -50,13 +50,13 @@ class Foo { var cs = 3 // OK val b = // OK - var e3 = 2 // error - val e1 = 1 // error - def e2 = 2 // error + var e3 = 2 // warn + val e1 = 1 // warn + def e2 = 2 // warn 1 val c = // OK - var e1 = 1 // error not set + var e1 = 1 // warn not set def e2 = e1 // OK val e3 = e2 // OK e3 @@ -71,14 +71,14 @@ class Foo { def d = 1 // OK def e = // OK - val e1 = 1 // error - def e2 = 2 // error - var e3 = 4 // error + val e1 = 1 // warn + def e2 = 2 // warn + var e3 = 4 // warn 1 def f = // OK val f1 = 1 // OK - var f2 = f1 // error not set + var f2 = f1 // warn not set def f3 = f2 // OK f3 @@ -99,18 +99,18 @@ package foo.scala2.tests: trait Locals { def f0 = { - var x = 1 // error + var x = 1 // warn var y = 2 // OK y = 3 y + y } def f1 = { val a = new Outer // OK - val b = new Outer // error + val b = new Outer // warn new a.Inner } def f2 = { - var x = 100 // error not set + var x = 100 // warn not set x } } @@ -118,14 +118,14 @@ package foo.scala2.tests: object Types { def l1() = { object HiObject { def f = this } // OK - class Hi { // error + class Hi { // warn def f1: Hi = new Hi def f2(x: Hi) = x } - class DingDongDoobie // error + class DingDongDoobie // warn class Bippy // OK type Something = Bippy // OK - type OtherThing = String // error + type OtherThing = String // warn (new Bippy): Something } } @@ -141,4 +141,4 @@ package test.foo.twisted.i16682: } isInt - def f = myPackage("42") + def f = myPackage("42") \ No newline at end of file diff --git a/tests/neg/i15503c.scala b/tests/warn/i15503c.scala similarity index 69% rename from tests/neg/i15503c.scala rename to tests/warn/i15503c.scala index 040dae43a2c9..e70df10f3140 100644 --- a/tests/neg/i15503c.scala +++ b/tests/warn/i15503c.scala @@ -1,29 +1,30 @@ -//> using options -Xfatal-warnings -Wunused:privates -source:3.3 +//> using options -Wunused:privates -source:3.3 + trait C class A: self: C => // OK class B: private[A] val a = 1 // OK private[B] val b = 1 // OK - private[this] val c = 1 // error - private val d = 1 // error + private[this] val c = 1 // warn + private val d = 1 // warn private[A] val e = 1 // OK private[this] val f = e // OK private val g = f // OK private[A] var h = 1 // OK - private[this] var i = h // error not set - private var j = i // error not set + private[this] var i = h // warn not set + private var j = i // warn not set private[this] var k = 1 // OK private var l = 2 // OK - private val m = // error + private val m = // warn k = l l = k l - private def fac(x: Int): Int = // error + private def fac(x: Int): Int = // warn if x == 0 then 1 else x * fac(x - 1) val x = 1 // OK @@ -34,10 +35,10 @@ class A: package foo.test.contructors: case class A private (x:Int) // OK class B private (val x: Int) // OK - class C private (private val x: Int) // error + class C private (private val x: Int) // warn class D private (private val x: Int): // OK def y = x - class E private (private var x: Int): // error not set + class E private (private var x: Int): // warn not set def y = x class F private (private var x: Int): // OK def y = @@ -54,4 +55,4 @@ package test.foo.i16682: case _ => println("NaN") } - def f = myPackage.isInt("42") + def f = myPackage.isInt("42") \ No newline at end of file diff --git a/tests/neg/i15503d.scala b/tests/warn/i15503d.scala similarity index 60% rename from tests/neg/i15503d.scala rename to tests/warn/i15503d.scala index c43dc07c638e..9a0ba9b2f8dc 100644 --- a/tests/neg/i15503d.scala +++ b/tests/warn/i15503d.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:unsafe-warn-patvars +//> using options -Wunused:unsafe-warn-patvars // todo : change to :patvars sealed trait Calc @@ -8,15 +8,15 @@ case class S(pred: Const) extends Const case object Z extends Const val a = Sum(S(S(Z)),Z) match { - case Sum(a,Z) => Z // error + case Sum(a,Z) => Z // warn // case Sum(a @ _,Z) => Z // todo : this should pass in the future - case Sum(a@S(_),Z) => Z // error - case Sum(a@S(_),Z) => a // OK - case Sum(a@S(b@S(_)), Z) => a // error - case Sum(a@S(b@S(_)), Z) => a // error - case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // OK + case Sum(a@S(_),Z) => Z // warn + case Sum(a@S(_),Z) => a // warn unreachable + case Sum(a@S(b@S(_)), Z) => a // warn + case Sum(a@S(b@S(_)), Z) => a // warn + case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // warn unreachable case Sum(_,_) => Z // OK - case _ => Z // OK + case _ => Z // warn unreachable } // todo : This should pass in the future @@ -27,4 +27,4 @@ val a = Sum(S(S(Z)),Z) match { // todo : This should *NOT* pass in the future // val c = for { // case Some(x) <- Option(Option(1)) -// } println(s"hello world") +// } println(s"hello world") \ No newline at end of file diff --git a/tests/neg/i15503e.scala b/tests/warn/i15503e.scala similarity index 81% rename from tests/neg/i15503e.scala rename to tests/warn/i15503e.scala index f3214e7b24e6..46d73a4945cd 100644 --- a/tests/neg/i15503e.scala +++ b/tests/warn/i15503e.scala @@ -1,14 +1,14 @@ -//> using options -Xfatal-warnings -Wunused:explicits +//> using options -Wunused:explicits object Foo { /* This goes around the "trivial method" detection */ val default_val = 1 private def f1(a: Int) = a // OK - private def f2(a: Int) = default_val // error + private def f2(a: Int) = default_val // warn private def f3(a: Int)(using Int) = a // OK - private def f4(a: Int)(using Int) = default_val // error - private def f6(a: Int)(using Int) = summon[Int] // error + private def f4(a: Int)(using Int) = default_val // warn + private def f6(a: Int)(using Int) = summon[Int] // warn private def f7(a: Int)(using Int) = summon[Int] + a // OK } @@ -49,9 +49,9 @@ package foo.test.trivial: private def f6(x: Int) = X // OK private def f7(x: Int) = Y // OK private def f8(x: Int): List[C] = Nil // OK - private def f9(x: Int): List[Int] = List(1,2,3,4) // error + private def f9(x: Int): List[Int] = List(1,2,3,4) // warn private def foo:Int = 32 // OK - private def f77(x: Int) = foo // error + private def f77(x: Int) = foo // warn } object Y @@ -67,5 +67,4 @@ package foo.test.i16865: def fn(a: Int, b: Int): Int = b + 3 // OK object Ex2 extends Bar: - override def fn(a: Int, b: Int): Int = b + 3 // OK - + override def fn(a: Int, b: Int): Int = b + 3 // OK \ No newline at end of file diff --git a/tests/neg/i15503f.scala b/tests/warn/i15503f.scala similarity index 77% rename from tests/neg/i15503f.scala rename to tests/warn/i15503f.scala index 08520d149b95..ccf0b7e74065 100644 --- a/tests/neg/i15503f.scala +++ b/tests/warn/i15503f.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:implicits +//> using options -Wunused:implicits /* This goes around the "trivial method" detection */ val default_int = 1 @@ -10,5 +10,5 @@ object Xd { private def f4(a: Int)(using Int) = default_int // OK private def f6(a: Int)(using Int) = summon[Int] // OK private def f7(a: Int)(using Int) = summon[Int] + a // OK - private def f8(a: Int)(using foo: Int) = a // error + private def f8(a: Int)(using foo: Int) = a // warn } diff --git a/tests/neg/i15503g.scala b/tests/warn/i15503g.scala similarity index 68% rename from tests/neg/i15503g.scala rename to tests/warn/i15503g.scala index 4da98a8d43f2..fbd9f3c1352c 100644 --- a/tests/neg/i15503g.scala +++ b/tests/warn/i15503g.scala @@ -1,14 +1,14 @@ -//> using options -Xfatal-warnings -Wunused:params +//> using options -Wunused:params /* This goes around the "trivial method" detection */ object Foo { val default_int = 1 private def f1(a: Int) = a // OK - private def f2(a: Int) = default_int // error + private def f2(a: Int) = default_int // warn private def f3(a: Int)(using Int) = a // OK - private def f4(a: Int)(using Int) = default_int // error - private def f6(a: Int)(using Int) = summon[Int] // error + private def f4(a: Int)(using Int) = default_int // warn + private def f6(a: Int)(using Int) = summon[Int] // warn private def f7(a: Int)(using Int) = summon[Int] + a // OK /* --- Trivial method check --- */ private def g1(x: Int) = 1 // OK @@ -20,4 +20,4 @@ package foo.test.i17101: extension[A] (x: Test[A]) { // OK def value: A = x def causesIssue: Unit = println("oh no") - } + } \ No newline at end of file diff --git a/tests/warn/i15503h.scala b/tests/warn/i15503h.scala new file mode 100644 index 000000000000..854693981488 --- /dev/null +++ b/tests/warn/i15503h.scala @@ -0,0 +1,20 @@ +//> using options -Wunused:linted + +import collection.mutable.Set // warn + +class A { + private val a = 1 // warn + val b = 2 // OK + + private def c = 2 // warn + def d(using x:Int): Int = b // ok + def e(x: Int) = 1 // OK + def f = + val x = 1 // warn + def f = 2 // warn + 3 + + def g(x: Int): Int = x match + case x:1 => 0 // OK + case _ => 1 +} \ No newline at end of file diff --git a/tests/neg/i15503i.scala b/tests/warn/i15503i.scala similarity index 88% rename from tests/neg/i15503i.scala rename to tests/warn/i15503i.scala index d415c95a701a..329b81327288 100644 --- a/tests/neg/i15503i.scala +++ b/tests/warn/i15503i.scala @@ -1,11 +1,11 @@ -//> using options -Xfatal-warnings -Wunused:all +//> using options -Wunused:all -import collection.mutable.{Map => MutMap} // error -import collection.mutable.Set // error +import collection.mutable.{Map => MutMap} // warn +import collection.mutable.Set // warn class A { import collection.mutable.{Map => MutMap} // OK - private val a = 1 // error + private val a = 1 // warn val b = 2 // OK /* This goes around the trivial method detection */ @@ -13,7 +13,7 @@ class A { val someMap = MutMap() - private def c1 = 2 // error + private def c1 = 2 // warn private def c2 = 2 // OK def c3 = c2 @@ -23,8 +23,8 @@ class A { def e1(x: Int) = default_int // ok def e2(x: Int) = x // OK def f = - val x = 1 // error - def f = 2 // error + val x = 1 // warn + def f = 2 // warn val y = 3 // OK def g = 4 // OK y + g @@ -49,7 +49,7 @@ package foo.test.scala.annotation: def a3(@unused a: Int) = default_int //OK def b1 = - def f = 1 // error + def f = 1 // warn 1 def b2 = @@ -61,7 +61,7 @@ package foo.test.scala.annotation: 1 object Foo: - private def a = 1 // error + private def a = 1 // warn private def b = 2 // OK @unused private def c = 3 // OK @@ -81,8 +81,8 @@ package foo.test.i16678: def run = println(foo(number => number.toString, value = 5)) // OK - println(foo(number => "", value = 5)) // error - println(foo(func = number => "", value = 5)) // error + println(foo(number => "", value = 5)) // warn + println(foo(func = number => "", value = 5)) // warn println(foo(func = number => number.toString, value = 5)) // OK println(foo(func = _.toString, value = 5)) // OK @@ -93,7 +93,7 @@ package foo.test.possibleclasses: )( s: Int, val t: Int, // OK - private val z: Int // error + private val z: Int // warn ) case class AllCaseUsed( @@ -108,12 +108,12 @@ package foo.test.possibleclasses: } class AllClass( - k: Int, // error - private val y: Int // error + k: Int, // warn + private val y: Int // warn )( - s: Int, // error + s: Int, // warn val t: Int, // OK - private val z: Int // error + private val z: Int // warn ) class AllUsed( @@ -134,7 +134,7 @@ package foo.test.possibleclasses.withvar: )( s: Int, var t: Int, // OK - private var z: Int // error + private var z: Int // warn ) case class AllCaseUsed( @@ -143,27 +143,27 @@ package foo.test.possibleclasses.withvar: )( s: Int, // OK var t: Int, // OK global scope can be set somewhere else - private var z: Int // error not set + private var z: Int // warn not set ) { def a = k + y + s + t + z } class AllClass( - k: Int, // error - private var y: Int // error + k: Int, // warn + private var y: Int // warn )( - s: Int, // error + s: Int, // warn var t: Int, // OK - private var z: Int // error + private var z: Int // warn ) class AllUsed( k: Int, // OK - private var y: Int // error not set + private var y: Int // warn not set )( s: Int, // OK var t: Int, // OK global scope can be set somewhere else - private var z: Int // error not set + private var z: Int // warn not set ) { def a = k + y + s + t + z } @@ -312,4 +312,4 @@ package foo.test.i17117: val test = t1.test } - } + } \ No newline at end of file diff --git a/tests/neg/i15503j.scala b/tests/warn/i15503j.scala similarity index 90% rename from tests/neg/i15503j.scala rename to tests/warn/i15503j.scala index 66140934abc1..f5e15bb79f79 100644 --- a/tests/neg/i15503j.scala +++ b/tests/warn/i15503j.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:strict-no-implicit-warn +//> using options -Wunused:strict-no-implicit-warn package foo.unused.strict.test: package a: @@ -12,8 +12,8 @@ package foo.unused.strict.test: import a.* // OK import a.x // OK import a.y // OK - import a.z // error - import a.f // error + import a.z // warn + import a.f // warn package c: import a.given // OK import a.x // OK diff --git a/tests/neg/i15662.scala b/tests/warn/i15662.scala similarity index 68% rename from tests/neg/i15662.scala rename to tests/warn/i15662.scala index c84ed6e5e341..0cf0e57ed0c3 100644 --- a/tests/neg/i15662.scala +++ b/tests/warn/i15662.scala @@ -1,10 +1,10 @@ -//> using options -Xfatal-warnings + case class Composite[T](v: T) def m(composite: Composite[?]): Unit = composite match { - case Composite[Int](v) => println(v) // error: cannot be checked at runtime + case Composite[Int](v) => println(v) // warn: cannot be checked at runtime } def m2(composite: Composite[?]): Unit = diff --git a/tests/neg/i15893.scala b/tests/warn/i15893.scala similarity index 83% rename from tests/neg/i15893.scala rename to tests/warn/i15893.scala index a62ddc3ae653..8e40964b2eca 100644 --- a/tests/neg/i15893.scala +++ b/tests/warn/i15893.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + sealed trait NatT case class Zero() extends NatT @@ -25,19 +25,19 @@ transparent inline def transparentInlineMod2(inline n: NatT): NatT = inline n m case Succ(Succ(predPredN)) => transparentInlineMod2(predPredN) def dependentlyTypedMod2[N <: NatT](n: N): Mod2[N] = n match - case Zero(): Zero => Zero() // error - case Succ(Zero()): Succ[Zero] => Succ(Zero()) // error - case Succ(Succ(predPredN)): Succ[Succ[?]] => dependentlyTypedMod2(predPredN) // error + case Zero(): Zero => Zero() // warn + case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn + case Succ(Succ(predPredN)): Succ[Succ[?]] => dependentlyTypedMod2(predPredN) // warn inline def inlineDependentlyTypedMod2[N <: NatT](inline n: N): Mod2[N] = inline n match - case Zero(): Zero => Zero() // error - case Succ(Zero()): Succ[Zero] => Succ(Zero()) // error - case Succ(Succ(predPredN)): Succ[Succ[?]] => inlineDependentlyTypedMod2(predPredN) // error + case Zero(): Zero => Zero() // warn + case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn + case Succ(Succ(predPredN)): Succ[Succ[?]] => inlineDependentlyTypedMod2(predPredN) // warn transparent inline def transparentInlineDependentlyTypedMod2[N <: NatT](inline n: N): Mod2[N] = inline n match - case Zero(): Zero => Zero() // error - case Succ(Zero()): Succ[Zero] => Succ(Zero()) // error - case Succ(Succ(predPredN)): Succ[Succ[?]] => transparentInlineDependentlyTypedMod2(predPredN) // error + case Zero(): Zero => Zero() // warn + case Succ(Zero()): Succ[Zero] => Succ(Zero()) // warn + case Succ(Succ(predPredN)): Succ[Succ[?]] => transparentInlineDependentlyTypedMod2(predPredN) // warn def foo(n: NatT): NatT = mod2(n) match case Succ(Zero()) => Zero() @@ -60,4 +60,4 @@ inline def transparentInlineFoo(inline n: NatT): NatT = inline transparentInline println(transparentInlineFoo(Succ(Succ(Succ(Zero()))))) // prints Zero(), as expected println(dependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // runtime error; unexpected println(inlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected - println(transparentInlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected + println(transparentInlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected \ No newline at end of file diff --git a/tests/neg/i16639a.scala b/tests/warn/i16639a.scala similarity index 67% rename from tests/neg/i16639a.scala rename to tests/warn/i16639a.scala index 5b348d594f5b..9fe4efe57d7b 100644 --- a/tests/neg/i16639a.scala +++ b/tests/warn/i16639a.scala @@ -1,35 +1,35 @@ -//> using options -Xfatal-warnings -Wunused:all -source:3.3 -// +//> using options -Wunused:all -source:3.3 + class Bippy(a: Int, b: Int) { - private def this(c: Int) = this(c, c) // warn /Dotty:NoWarn - private def boop(x: Int) = x+a+b // error - private def bippy(x: Int): Int = bippy(x) // error TODO: could warn - final private val MILLIS1 = 2000 // error no warn, /Dotty:Warn - final private val MILLIS2: Int = 1000 // error + private def this(c: Int) = this(c, c) + private def boop(x: Int) = x+a+b // warn + private def bippy(x: Int): Int = bippy(x) // warn TODO: could warn + final private val MILLIS1 = 2000 // warn no warn, /Dotty:Warn + final private val MILLIS2: Int = 1000 // warn final private val HI_COMPANION: Int = 500 // no warn, accessed from companion def hi() = Bippy.HI_INSTANCE } object Bippy { def hi(x: Bippy) = x.HI_COMPANION private val HI_INSTANCE: Int = 500 // no warn, accessed from instance - private val HEY_INSTANCE: Int = 1000 // error warn - private lazy val BOOL: Boolean = true // error warn + private val HEY_INSTANCE: Int = 1000 // warn warn + private lazy val BOOL: Boolean = true // warn warn } class A(val msg: String) class B1(msg: String) extends A(msg) class B2(msg0: String) extends A(msg0) -class B3(msg0: String) extends A("msg") // error /Dotty: unused explicit parameter +class B3(msg0: String) extends A("msg") // warn /Dotty: unused explicit parameter trait Bing trait Accessors { - private var v1: Int = 0 // error warn - private var v2: Int = 0 // error warn, never set + private var v1: Int = 0 // warn warn + private var v2: Int = 0 // warn warn, never set private var v3: Int = 0 private var v4: Int = 0 // no warn - private[this] var v5 = 0 // error warn, never set + private[this] var v5 = 0 // warn warn, never set private[this] var v6 = 0 private[this] var v7 = 0 // no warn @@ -43,12 +43,12 @@ trait Accessors { } class StableAccessors { - private var s1: Int = 0 // error warn - private var s2: Int = 0 // error warn, never set - private var s3: Int = 0 // warn, never got /Dotty: no warn even if not usued + private var s1: Int = 0 // warn warn + private var s2: Int = 0 // warn warn, never set + private var s3: Int = 0 private var s4: Int = 0 // no warn - private[this] var s5 = 0 // error warn, never set + private[this] var s5 = 0 // warn warn, never set private[this] var s6 = 0 // no warn, limitation /Dotty: Why limitation ? private[this] var s7 = 0 // no warn @@ -62,7 +62,6 @@ class StableAccessors { } trait DefaultArgs { - // warn about default getters for x2 and x3 private def bippy(x1: Int, x2: Int = 10, x3: Int = 15): Int = x1 + x2 + x3 // no more warn warn since #17061 def boppy() = bippy(5, 100, 200) @@ -75,27 +74,27 @@ class Outer { trait Locals { def f0 = { - var x = 1 // error warn + var x = 1 // warn warn var y = 2 y = 3 y + y } def f1 = { val a = new Outer // no warn - val b = new Outer // error warn + val b = new Outer // warn warn new a.Inner } def f2 = { - var x = 100 // error warn about it being a var, var not set + var x = 100 // warn warn about it being a var, var not set x } } object Types { private object Dongo { def f = this } // no more warn since #17061 - private class Bar1 // error warn + private class Bar1 // warn warn private class Bar2 // no warn - private type Alias1 = String // error warn + private type Alias1 = String // warn warn private type Alias2 = String // no warn def bippo = (new Bar2).toString @@ -103,14 +102,14 @@ object Types { def l1() = { object HiObject { def f = this } // no more warn since #17061 - class Hi { // error warn + class Hi { // warn warn def f1: Hi = new Hi def f2(x: Hi) = x } - class DingDongDoobie // error warn + class DingDongDoobie // warn warn class Bippy // no warn type Something = Bippy // no warn - type OtherThing = String // error warn + type OtherThing = String // warn warn (new Bippy): Something } } @@ -126,7 +125,7 @@ trait Underwarn { class OtherNames { private def x_=(i: Int): Unit = () // no more warn since #17061 - private def x: Int = 42 // error Dotty triggers unused private member : To investigate + private def x: Int = 42 // warn Dotty triggers unused private member : To investigate private def y_=(i: Int): Unit = () // // no more warn since #17061 private def y: Int = 42 @@ -152,7 +151,7 @@ trait Forever { } trait Ignorance { - private val readResolve = 42 // error ignore /dotty triggers unused private member/ why should we ignore ? + private val readResolve = 42 // warn ignore /dotty triggers unused private member/ why should we ignore ? } trait CaseyKasem { @@ -190,7 +189,7 @@ class `no warn in patmat anonfun isDefinedAt` { class `nonprivate alias is enclosing` { class C type C2 = C - private class D extends C2 // error warn + private class D extends C2 // warn warn } object `classof something` { @@ -200,8 +199,7 @@ object `classof something` { trait `short comings` { def f: Int = { - val x = 42 // error /Dotty only triggers in dotty + val x = 42 // warn /Dotty only triggers in dotty 17 } -} - +} \ No newline at end of file diff --git a/tests/neg/i16649-refutable.check b/tests/warn/i16649-refutable.check similarity index 78% rename from tests/neg/i16649-refutable.check rename to tests/warn/i16649-refutable.check index a1325d7cfa91..a6cacfc691ee 100644 --- a/tests/neg/i16649-refutable.check +++ b/tests/warn/i16649-refutable.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i16649-refutable.scala:6:6 ------------------------------------------------------------------------- -6 | val '{ ($y: Int) + ($z: Int) } = x // error +-- Warning: tests/warn/i16649-refutable.scala:6:6 ---------------------------------------------------------------------- +6 | val '{ ($y: Int) + ($z: Int) } = x // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | pattern binding uses refutable extractor `'{...}` | diff --git a/tests/neg/i16649-refutable.scala b/tests/warn/i16649-refutable.scala similarity index 59% rename from tests/neg/i16649-refutable.scala rename to tests/warn/i16649-refutable.scala index 8caac5b2576a..5ff18b5a3633 100644 --- a/tests/neg/i16649-refutable.scala +++ b/tests/warn/i16649-refutable.scala @@ -1,9 +1,10 @@ -//> using options -Xfatal-warnings + import quoted.* def foo(using Quotes)(x: Expr[Int]) = - val '{ ($y: Int) + ($z: Int) } = x // error + val '{ ($y: Int) + ($z: Int) } = x // warn val '{ $a: Int } = x val '{ $b: Any } = x val '{ $c } = x + diff --git a/tests/neg/i16728.check b/tests/warn/i16728.check similarity index 55% rename from tests/neg/i16728.check rename to tests/warn/i16728.check index 93cc215696c2..117b2bd0c4d4 100644 --- a/tests/neg/i16728.check +++ b/tests/warn/i16728.check @@ -1,5 +1,5 @@ --- [E092] Pattern Match Error: tests/neg/i16728.scala:18:11 ------------------------------------------------------------ -18 | case tx : C[Int]#X => // error +-- [E092] Pattern Match Unchecked Warning: tests/warn/i16728.scala:18:11 ----------------------------------------------- +18 | case tx : C[Int]#X => // warn | ^ | the type test for C[Int] cannot be checked at runtime because its type arguments can't be determined from A | diff --git a/tests/neg/i16728.scala b/tests/warn/i16728.scala similarity index 87% rename from tests/neg/i16728.scala rename to tests/warn/i16728.scala index b76bb03fa14a..4d28b07c51a3 100644 --- a/tests/neg/i16728.scala +++ b/tests/warn/i16728.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class A[T] { class X { @@ -15,7 +15,7 @@ object Test { val b0x : A[?]#X = new b0.X def test = b0x match { - case tx : C[Int]#X => // error + case tx : C[Int]#X => // warn val c : C[Int] = tx.outer c case _ => @@ -31,4 +31,4 @@ object Test { } } -} \ No newline at end of file +} diff --git a/tests/neg/i16930.scala b/tests/warn/i16930.scala similarity index 70% rename from tests/neg/i16930.scala rename to tests/warn/i16930.scala index c7af60161424..bf30fccbf601 100644 --- a/tests/neg/i16930.scala +++ b/tests/warn/i16930.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:imports +//> using options -Wunused:imports trait Outer: trait Used @@ -6,7 +6,7 @@ trait Outer: object Test { val outer: Outer = ??? - import outer.{Used, Unused} // error + import outer.{Used, Unused} // warn def foo(x: Any): Used = x.asInstanceOf[Used] } @@ -17,6 +17,6 @@ trait Outer1: object Test1 { val outer1: Outer1 = ??? - import outer1.{Unused1, UnusedToo1} // error // error + import outer1.{Unused1, UnusedToo1} // warn // warn def foo() = outer1.unusedToo1 // in this case UnusedToo1 is not used explicitly, only inferred -} +} \ No newline at end of file diff --git a/tests/neg/i17266.check b/tests/warn/i17266.check similarity index 83% rename from tests/neg/i17266.check rename to tests/warn/i17266.check index 1a84d1bf5e89..716cd531dd0a 100644 --- a/tests/neg/i17266.check +++ b/tests/warn/i17266.check @@ -1,5 +1,5 @@ --- [E181] Potential Issue Error: tests/neg/i17266.scala:4:2 ------------------------------------------------------------ -4 | synchronized { // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:4:2 --------------------------------------------------------- +4 | synchronized { // warn | ^^^^^^^^^^^^ | Suspicious top-level unqualified call to synchronized |--------------------------------------------------------------------------------------------------------------------- @@ -9,8 +9,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. --------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:17:2 ----------------------------------------------------------- -17 | synchronized { // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:17:2 -------------------------------------------------------- +17 | synchronized { // warn | ^^^^^^^^^^^^ | Suspicious top-level unqualified call to synchronized |-------------------------------------------------------------------------------------------------------------------- @@ -20,8 +20,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. -------------------------------------------------------------------------------------------------------------------- --- [E187] Potential Issue Error: tests/neg/i17266.scala:22:4 ----------------------------------------------------------- -22 | 1.synchronized { // error +-- [E187] Potential Issue Warning: tests/warn/i17266.scala:22:4 -------------------------------------------------------- +22 | 1.synchronized { // warn | ^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |-------------------------------------------------------------------------------------------------------------------- @@ -30,8 +30,8 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. -------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:108:2 ---------------------------------------------------------- -108 | wait() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:108:2 ------------------------------------------------------- +108 | wait() // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -41,8 +41,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:115:2 ---------------------------------------------------------- -115 | wait() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:115:2 ------------------------------------------------------- +115 | wait() // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -52,8 +52,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:121:2 ---------------------------------------------------------- -121 | wait(10) // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:121:2 ------------------------------------------------------- +121 | wait(10) // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -63,8 +63,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:128:2 ---------------------------------------------------------- -128 | wait(10) // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:128:2 ------------------------------------------------------- +128 | wait(10) // warn | ^^^^ | Suspicious top-level unqualified call to wait |------------------------------------------------------------------------------------------------------------------- @@ -74,8 +74,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:134:2 ---------------------------------------------------------- -134 | hashCode() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:134:2 ------------------------------------------------------- +134 | hashCode() // warn | ^^^^^^^^ | Suspicious top-level unqualified call to hashCode |------------------------------------------------------------------------------------------------------------------- @@ -85,8 +85,8 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- --- [E181] Potential Issue Error: tests/neg/i17266.scala:141:2 ---------------------------------------------------------- -141 | hashCode() // error +-- [E181] Potential Issue Warning: tests/warn/i17266.scala:141:2 ------------------------------------------------------- +141 | hashCode() // warn | ^^^^^^^^ | Suspicious top-level unqualified call to hashCode |------------------------------------------------------------------------------------------------------------------- diff --git a/tests/neg/i17266.scala b/tests/warn/i17266.scala similarity index 86% rename from tests/neg/i17266.scala rename to tests/warn/i17266.scala index 439abafc44a1..7e0c9f1b653b 100644 --- a/tests/neg/i17266.scala +++ b/tests/warn/i17266.scala @@ -1,7 +1,7 @@ -//> using options -Werror -explain +//> using options -explain def test1 = - synchronized { // error + synchronized { // warn println("hello") } @@ -14,12 +14,12 @@ object MyLib def test3 = import MyLib.* - synchronized { // error + synchronized { // warn println("hello") } def test4 = - 1.synchronized { // error + 1.synchronized { // warn println("hello") } @@ -105,40 +105,40 @@ trait Test15: } def test16 = - wait() // error + wait() // warn def test17 = this.wait() // not an error (should be?) def test18 = import MyLib.* - wait() // error + wait() // warn def test19 = 1.wait() // not an error (should be?) def test20 = - wait(10) // error + wait(10) // warn def test21 = this.wait(10) // not an error (should be?) def test22 = import MyLib.* - wait(10) // error + wait(10) // warn def test23 = 1.wait(10) // not an error (should be?) def test24 = - hashCode() // error + hashCode() // warn def test25 = this.hashCode() // not an error (should be?) def test26 = import MyLib.* - hashCode() // error + hashCode() // warn def test27 = - 1.hashCode()// not an error (should be? probably not) + 1.hashCode()// not an error (should be? probably not) \ No newline at end of file diff --git a/tests/neg/i17314b.scala b/tests/warn/i17314b.scala similarity index 63% rename from tests/neg/i17314b.scala rename to tests/warn/i17314b.scala index 9e89fecde935..e1500028ca93 100644 --- a/tests/neg/i17314b.scala +++ b/tests/warn/i17314b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wunused:all +//> using options -Wunused:all package foo: class Foo[T] @@ -6,9 +6,10 @@ package foo: package bar: - import foo.{given foo.Foo[Int]} // error + import foo.{given foo.Foo[Int]} // warn import foo.Foo given Foo[Int] = ??? val repro: Foo[Int] = summon[Foo[Int]] + diff --git a/tests/neg/i17612a.check b/tests/warn/i17612a.check similarity index 62% rename from tests/neg/i17612a.check rename to tests/warn/i17612a.check index 04a5b07b6e33..67b489f17a91 100644 --- a/tests/neg/i17612a.check +++ b/tests/warn/i17612a.check @@ -1,32 +1,32 @@ --- Error: tests/neg/i17612a.scala:18:15 -------------------------------------------------------------------------------- -18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/warn/i17612a.scala:18:15 ----------------------------------------------------------------------------- +18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y | ^ | value x in class Derived shadows field x inherited from class Base --- Error: tests/neg/i17612a.scala:18:24 -------------------------------------------------------------------------------- -18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/warn/i17612a.scala:18:24 ----------------------------------------------------------------------------- +18 | class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y | ^ | value y in class Derived shadows field y inherited from class Base --- Error: tests/neg/i17612a.scala:20:2 --------------------------------------------------------------------------------- -20 | private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) +-- Warning: tests/warn/i17612a.scala:20:2 ------------------------------------------------------------------------------ +20 | private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) | ^ | value shadowed2 in class Derived shadows field shadowed2 inherited from class Base --- Error: tests/neg/i17612a.scala:21:2 --------------------------------------------------------------------------------- -21 | private[this] val shadowed3 = 3 + 3 // error +-- Warning: tests/warn/i17612a.scala:21:2 ------------------------------------------------------------------------------ +21 | private[this] val shadowed3 = 3 + 3 // warn | ^ | value shadowed3 in class Derived shadows field shadowed3 inherited from class Base --- Error: tests/neg/i17612a.scala:23:2 --------------------------------------------------------------------------------- -23 | private val shadowed5 = 5 + 5 // error +-- Warning: tests/warn/i17612a.scala:23:2 ------------------------------------------------------------------------------ +23 | private val shadowed5 = 5 + 5 // warn | ^ | value shadowed5 in class Derived shadows field shadowed5 inherited from class Base --- Error: tests/neg/i17612a.scala:34:20 -------------------------------------------------------------------------------- -34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error +-- Warning: tests/warn/i17612a.scala:34:20 ----------------------------------------------------------------------------- +34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn | ^ | value x in class UnderDerived shadows field x inherited from class Base --- Error: tests/neg/i17612a.scala:34:28 -------------------------------------------------------------------------------- -34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error +-- Warning: tests/warn/i17612a.scala:34:28 ----------------------------------------------------------------------------- +34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn | ^ | value y in class UnderDerived shadows field y inherited from class Base --- Error: tests/neg/i17612a.scala:34:36 -------------------------------------------------------------------------------- -34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error +-- Warning: tests/warn/i17612a.scala:34:36 ----------------------------------------------------------------------------- +34 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn | ^ | value z in class UnderDerived shadows field z inherited from class Base diff --git a/tests/neg/i17612a.scala b/tests/warn/i17612a.scala similarity index 76% rename from tests/neg/i17612a.scala rename to tests/warn/i17612a.scala index 099b528965e1..7473d8fd9ec9 100644 --- a/tests/neg/i17612a.scala +++ b/tests/warn/i17612a.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Xlint:private-shadow -source:3.3 +//> using options -Xlint:private-shadow -source:3.3 object i17612a: class Base(var x: Int, val y: Int, var z: Int): @@ -15,12 +15,12 @@ object i17612a: def increment(): Unit = x = x + 1 - class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y + class Derived(x : Int, y: Int, z2: Int) extends Base(x, y + 1, z2): // warn // warn / for x, y translated to private[this] x field & shadowing var Base.x, Base.y private def hello() = 4 - private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) - private[this] val shadowed3 = 3 + 3 // error + private val shadowed2 = 2 + 2 // warn (In Scala 2 we cannot do that got the warning) + private[this] val shadowed3 = 3 + 3 // warn //private[Derived] val fatalOverride = 0 // value fatalOverride of type Int has weaker access privileges; it should be public - private val shadowed5 = 5 + 5 // error + private val shadowed5 = 5 + 5 // warn private val notShadowed2 = -4 //protected var shadowed6 = 6 + 6 // variable shadowed6 of type Int has weaker access privileges; it should be public @@ -31,7 +31,7 @@ object i17612a: override def toString = s"x : ${x.toString}, y : ${y.toString}" - class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // error // error // error + class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, y, z) // warn // warn // warn def main(args: Array[String]) = val derived = new Derived(1, 1, 1) diff --git a/tests/neg/i17613a.check b/tests/warn/i17613a.check similarity index 57% rename from tests/neg/i17613a.check rename to tests/warn/i17613a.check index 4721b786c82d..6e40d102b1a4 100644 --- a/tests/neg/i17613a.check +++ b/tests/warn/i17613a.check @@ -1,28 +1,28 @@ --- Error: tests/neg/i17613a.scala:8:13 --------------------------------------------------------------------------------- -8 | def foobar[D](in: D) = in.toString // error method parameter shadows some other type +-- Warning: tests/warn/i17613a.scala:8:13 ------------------------------------------------------------------------------ +8 | def foobar[D](in: D) = in.toString // warn method parameter shadows some other type | ^ | Type parameter D for method foobar shadows the type defined by trait D in class B --- Error: tests/neg/i17613a.scala:9:13 --------------------------------------------------------------------------------- -9 | type MySeq[D] = Seq[D] // error type member's parameter shadows some other type +-- Warning: tests/warn/i17613a.scala:9:13 ------------------------------------------------------------------------------ +9 | type MySeq[D] = Seq[D] // warn type member's parameter shadows some other type | ^ | Type parameter D for type MySeq shadows the type defined by trait D in class B --- Error: tests/neg/i17613a.scala:11:12 -------------------------------------------------------------------------------- -11 | class Foo[T](t: T): // error class parameter shadows some other type +-- Warning: tests/warn/i17613a.scala:11:12 ----------------------------------------------------------------------------- +11 | class Foo[T](t: T): // warn class parameter shadows some other type | ^ | Type parameter T for class Foo shadows the type defined by type T in class B --- Error: tests/neg/i17613a.scala:12:11 -------------------------------------------------------------------------------- -12 | def bar[T](w: T) = w.toString // error a type parameter shadows another type parameter +-- Warning: tests/warn/i17613a.scala:12:11 ----------------------------------------------------------------------------- +12 | def bar[T](w: T) = w.toString // warn a type parameter shadows another type parameter | ^ | Type parameter T for method bar shadows the type defined by type T in class Foo --- Error: tests/neg/i17613a.scala:15:12 -------------------------------------------------------------------------------- -15 | class C[M[List[_]]] // error +-- Warning: tests/warn/i17613a.scala:15:12 ----------------------------------------------------------------------------- +15 | class C[M[List[_]]] // warn | ^^^^^^^ | Type parameter List for class C shadows the type defined by type List in package scala --- Error: tests/neg/i17613a.scala:16:11 -------------------------------------------------------------------------------- -16 | type E[M[List[_]]] = Int // error +-- Warning: tests/warn/i17613a.scala:16:11 ----------------------------------------------------------------------------- +16 | type E[M[List[_]]] = Int // warn | ^^^^^^^ | Type parameter List for type E shadows the type defined by type List in package scala --- Error: tests/neg/i17613a.scala:17:14 -------------------------------------------------------------------------------- -17 | def foo[N[M[List[_]]]] = ??? // error +-- Warning: tests/warn/i17613a.scala:17:14 ----------------------------------------------------------------------------- +17 | def foo[N[M[List[_]]]] = ??? // warn | ^^^^^^^ | Type parameter List for method foo shadows the type defined by type List in package scala diff --git a/tests/warn/i17613a.scala b/tests/warn/i17613a.scala new file mode 100644 index 000000000000..6ee55a5cf973 --- /dev/null +++ b/tests/warn/i17613a.scala @@ -0,0 +1,23 @@ +//> using options -Xlint:type-parameter-shadow + +object i17613a: + class B: + type T = Int + trait D + + def foobar[D](in: D) = in.toString // warn method parameter shadows some other type + type MySeq[D] = Seq[D] // warn type member's parameter shadows some other type + + class Foo[T](t: T): // warn class parameter shadows some other type + def bar[T](w: T) = w.toString // warn a type parameter shadows another type parameter + + // even deeply nested... + class C[M[List[_]]] // warn + type E[M[List[_]]] = Int // warn + def foo[N[M[List[_]]]] = ??? // warn + + // ...but not between type parameters in the same list + class F[A, M[N[A]]] + type G[A, M[L[A]]] = Int + def bar[A, N[M[L[A]]]] = ??? + def main(args: Array[String]) = println("Test for type parameter shadow") \ No newline at end of file diff --git a/tests/neg/i18722.check b/tests/warn/i18722.check similarity index 89% rename from tests/neg/i18722.check rename to tests/warn/i18722.check index 539e23787752..4fae07e15204 100644 --- a/tests/neg/i18722.check +++ b/tests/warn/i18722.check @@ -1,5 +1,5 @@ --- [E190] Potential Issue Error: tests/neg/i18722.scala:3:15 ----------------------------------------------------------- -3 |def f1: Unit = null // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:3:15 -------------------------------------------------------- +3 |def f1: Unit = null // warn | ^^^^ | Discarded non-Unit value of type Null. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -9,8 +9,8 @@ | Here the `null` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- --- [E190] Potential Issue Error: tests/neg/i18722.scala:4:15 ----------------------------------------------------------- -4 |def f2: Unit = 1 // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:4:15 -------------------------------------------------------- +4 |def f2: Unit = 1 // warn | ^ | Discarded non-Unit value of type Int. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -20,8 +20,8 @@ | Here the `1` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- --- [E190] Potential Issue Error: tests/neg/i18722.scala:5:15 ----------------------------------------------------------- -5 |def f3: Unit = "a" // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:5:15 -------------------------------------------------------- +5 |def f3: Unit = "a" // warn | ^^^ | Discarded non-Unit value of type String. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -31,8 +31,8 @@ | Here the `"a"` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- --- [E190] Potential Issue Error: tests/neg/i18722.scala:7:15 ----------------------------------------------------------- -7 |def f4: Unit = i // error +-- [E190] Potential Issue Warning: tests/warn/i18722.scala:7:15 -------------------------------------------------------- +7 |def f4: Unit = i // warn | ^ | Discarded non-Unit value of type Int. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- diff --git a/tests/warn/i18722.scala b/tests/warn/i18722.scala new file mode 100644 index 000000000000..246640a349b4 --- /dev/null +++ b/tests/warn/i18722.scala @@ -0,0 +1,9 @@ +//> using options -explain + +def f1: Unit = null // warn +def f2: Unit = 1 // warn +def f3: Unit = "a" // warn +val i: Int = 1 +def f4: Unit = i // warn +val u: Unit = () +def f5: Unit = u \ No newline at end of file diff --git a/tests/neg/i18862-3.4.check b/tests/warn/i18862-3.4.check similarity index 70% rename from tests/neg/i18862-3.4.check rename to tests/warn/i18862-3.4.check index b56454feeeaa..8dd5058d305e 100644 --- a/tests/neg/i18862-3.4.check +++ b/tests/warn/i18862-3.4.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i18862-3.4.scala:6:38 ------------------------------------------------------------------------------ -6 |def test(xs: List[Int]): Unit = f(xs: _*) // error: migration warning +-- Warning: tests/warn/i18862-3.4.scala:4:38 --------------------------------------------------------------------------- +4 |def test(xs: List[Int]): Unit = f(xs: _*) // warn: migration warning | ^ | The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead | This construct can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/warn/i18862-3.4.scala b/tests/warn/i18862-3.4.scala new file mode 100644 index 000000000000..6d9cf8c71f7b --- /dev/null +++ b/tests/warn/i18862-3.4.scala @@ -0,0 +1,4 @@ +import scala.language.`3.4` + +def f(x: Int*): Unit = () +def test(xs: List[Int]): Unit = f(xs: _*) // warn: migration warning diff --git a/tests/warn/i18862-future-migration.scala b/tests/warn/i18862-future-migration.scala new file mode 100644 index 000000000000..02225b67435a --- /dev/null +++ b/tests/warn/i18862-future-migration.scala @@ -0,0 +1,4 @@ +import scala.language.`future-migration` + +def f(x: Int*): Unit = () +def test(xs: List[Int]): Unit = f(xs: _*) // warn: migration warning diff --git a/tests/warn/i18867-3.4.scala b/tests/warn/i18867-3.4.scala new file mode 100644 index 000000000000..e2630c0cb95c --- /dev/null +++ b/tests/warn/i18867-3.4.scala @@ -0,0 +1,5 @@ +import language.`3.4` + +def foo(x: Int) = x + +def test = foo _ // warn diff --git a/tests/neg/i18867.check b/tests/warn/i18867.check similarity index 76% rename from tests/neg/i18867.check rename to tests/warn/i18867.check index 014e9e7bd92e..226496d8e74b 100644 --- a/tests/neg/i18867.check +++ b/tests/warn/i18867.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i18867.scala:5:15 ---------------------------------------------------------------------------------- -5 |def test = foo _ // error +-- Warning: tests/warn/i18867.scala:3:15 ------------------------------------------------------------------------------- +3 |def test = foo _ // warn | ^^^^^ | The syntax ` _` is no longer supported; | you can simply leave out the trailing ` _` diff --git a/tests/warn/i18867.scala b/tests/warn/i18867.scala new file mode 100644 index 000000000000..a16d67b89919 --- /dev/null +++ b/tests/warn/i18867.scala @@ -0,0 +1,3 @@ +def foo(x: Int) = x + +def test = foo _ // warn diff --git a/tests/warn/i2333.scala b/tests/warn/i2333.scala new file mode 100644 index 000000000000..1ac5eb314325 --- /dev/null +++ b/tests/warn/i2333.scala @@ -0,0 +1,11 @@ +//> using options -deprecation + +@deprecated("bla", "2.11.0") class Foo { + println("") + def this(x: Int) = this() +} + +object Test { + new Foo // warn: deprecated + new Foo(1) // warn: deprecated +} \ No newline at end of file diff --git a/tests/warn/i2673.scala b/tests/warn/i2673.scala new file mode 100644 index 000000000000..a04e3b370d56 --- /dev/null +++ b/tests/warn/i2673.scala @@ -0,0 +1,6 @@ + + +package Foos + +class Foo // warn +class foo diff --git a/tests/warn/i2673b.scala b/tests/warn/i2673b.scala new file mode 100644 index 000000000000..0d11317cd9e6 --- /dev/null +++ b/tests/warn/i2673b.scala @@ -0,0 +1,7 @@ + + +package Foos + +class Bar // warn +object bar + diff --git a/tests/warn/i2673c.scala b/tests/warn/i2673c.scala new file mode 100644 index 000000000000..682e4adfa2c9 --- /dev/null +++ b/tests/warn/i2673c.scala @@ -0,0 +1,9 @@ + + +package Foos + +object Outer { + case class X() // warn + object x +} + diff --git a/tests/warn/i3324.scala b/tests/warn/i3324.scala new file mode 100644 index 000000000000..ab0c24da39a5 --- /dev/null +++ b/tests/warn/i3324.scala @@ -0,0 +1,6 @@ + + +class Foo { + def foo(x: Any): Boolean = + x.isInstanceOf[List[String]] // warn +} diff --git a/tests/neg/i3561.scala b/tests/warn/i3561.scala similarity index 51% rename from tests/neg/i3561.scala rename to tests/warn/i3561.scala index 862e65f3c2f7..a64a599eafec 100644 --- a/tests/neg/i3561.scala +++ b/tests/warn/i3561.scala @@ -1,18 +1,18 @@ -//> using options -Xfatal-warnings + class Test { val Constant = 'Q' // OK if final - def tokenMe(ch: Char) = (ch: @annotation.switch) match { // error: could not emit switch + def tokenMe(ch: Char) = (ch: @annotation.switch) match { // warn: could not emit switch case ' ' => 1 case 'A' => 2 case '5' | Constant => 3 case '4' => 4 } - def test2(x: Any) = (x: @annotation.switch) match { // error: could not emit switch + def test2(x: Any) = (x: @annotation.switch) match { // warn: could not emit switch case ' ' => 1 case 'A' => 2 case '5' | Constant => 3 case '4' => 4 } -} +} \ No newline at end of file diff --git a/tests/neg/i4008.check b/tests/warn/i4008.check similarity index 80% rename from tests/neg/i4008.check rename to tests/warn/i4008.check index c1f27866d1c1..b72e7a8c20c5 100644 --- a/tests/neg/i4008.check +++ b/tests/warn/i4008.check @@ -1,40 +1,40 @@ --- [E158] Reference Error: tests/neg/i4008.scala:7:56 ------------------------------------------------------------------ -7 |@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:7:56 --------------------------------------------------------------- +7 |@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn1`. --- [E158] Reference Error: tests/neg/i4008.scala:11:56 ----------------------------------------------------------------- -11 |@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:11:56 -------------------------------------------------------------- +11 |@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // warn | ^ | Invalid reference to a type variable `A` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn2`. --- [E158] Reference Error: tests/neg/i4008.scala:15:56 ----------------------------------------------------------------- -15 |@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:15:56 -------------------------------------------------------------- +15 |@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // warn | ^ | Invalid reference to a type variable `A` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn3`. --- [E158] Reference Error: tests/neg/i4008.scala:19:56 ----------------------------------------------------------------- -19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error +-- [E158] Reference Warning: tests/warn/i4008.scala:19:56 -------------------------------------------------------------- +19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // warn // warn | ^ | Invalid reference to a type variable `A` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn4`. --- [E158] Reference Error: tests/neg/i4008.scala:19:61 ----------------------------------------------------------------- -19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error +-- [E158] Reference Warning: tests/warn/i4008.scala:19:61 -------------------------------------------------------------- +19 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // warn // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn4`. --- [E158] Reference Error: tests/neg/i4008.scala:23:61 ----------------------------------------------------------------- -23 |@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // error +-- [E158] Reference Warning: tests/warn/i4008.scala:23:61 -------------------------------------------------------------- +23 |@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // warn | ^ | Invalid reference to a type variable `Abc` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `ShouldWarn5`. --- [E158] Reference Error: tests/neg/i4008.scala:46:54 ----------------------------------------------------------------- -46 |class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // error +-- [E158] Reference Warning: tests/warn/i4008.scala:46:54 -------------------------------------------------------------- +46 |class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of the constructor of `C`. --- [E158] Reference Error: tests/neg/i4008.scala:48:62 ----------------------------------------------------------------- -48 |def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // error +-- [E158] Reference Warning: tests/warn/i4008.scala:48:62 -------------------------------------------------------------- +48 |def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // warn | ^ | Invalid reference to a type variable `B` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `someMethod1`. diff --git a/tests/neg/i4008.scala b/tests/warn/i4008.scala similarity index 86% rename from tests/neg/i4008.scala rename to tests/warn/i4008.scala index 5b851c987e37..489a067bf6fd 100644 --- a/tests/neg/i4008.scala +++ b/tests/warn/i4008.scala @@ -1,26 +1,26 @@ -//> using options -Xfatal-warnings + // ===== Template annotations ===== // class, 1TP, invalid ref -@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // warn class ShouldWarn1[A] // trait, 1TP, invalid ref -@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // warn trait ShouldWarn2[B] // trait, 2TP, 1 invalid ref -@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // warn trait ShouldWarn3[B, C] // class, 2TP, 2 invalid refs -@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error +@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // warn // warn class ShouldWarn4[C, D] // class, 2TP, 1 invalid multi-char refs -@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // error +@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // warn class ShouldWarn5[C, D] // trait, 1TP, valid ref @@ -43,8 +43,8 @@ class ShouldntWarn4[Hello, World] @annotation.implicitNotFound("Hopefully you don't see this!") -class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // error +class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // warn -def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // error +def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // warn def someMethod2[A](using @annotation.implicitNotFound("No C[${A}] found") sc: C[A]) = "" \ No newline at end of file diff --git a/tests/warn/i4297.scala b/tests/warn/i4297.scala new file mode 100644 index 000000000000..a34c3a5de584 --- /dev/null +++ b/tests/warn/i4297.scala @@ -0,0 +1,14 @@ + + +class Test { + def test[X <: Option[Int]](x: X) = x.isInstanceOf[Some[Int]] + def test1[Y <: Int, X <: Option[Y]](x: X) = x.isInstanceOf[Some[Int]] + def test2(x: Any) = x.isInstanceOf[Function1[Nothing, ?]] + def test3a(x: Any) = x.isInstanceOf[Function1[Any, ?]] // warn + def test3b(x: Any) = x.isInstanceOf[Function1[Int, ?]] // warn + def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, ?]] // warn + def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // warn + def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // warn + def test7[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[?, Unit]] +} + diff --git a/tests/neg/i4364.scala b/tests/warn/i4364.scala similarity index 61% rename from tests/neg/i4364.scala rename to tests/warn/i4364.scala index 85dca443f6d4..5cfc2ed5076d 100644 --- a/tests/neg/i4364.scala +++ b/tests/warn/i4364.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object Test { def foo(c: java.util.function.Consumer[Integer]) = c.accept(0) @@ -6,6 +6,6 @@ object Test { def main(args: Array[String]) = { foo(f) // Ok: Consumer is @FunctionalInterface - new java.io.ObjectOutputStream(f) // error: OutputStream is not @FunctionalInterface + new java.io.ObjectOutputStream(f) // warn: OutputStream is not @FunctionalInterface } } diff --git a/tests/warn/i4812.check b/tests/warn/i4812.check new file mode 100644 index 000000000000..a09e91b4c797 --- /dev/null +++ b/tests/warn/i4812.check @@ -0,0 +1,42 @@ +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:8:11 ------------------------------------------------- +8 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:18:11 ------------------------------------------------ +18 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:28:11 ------------------------------------------------ +28 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:38:11 ------------------------------------------------ +38 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:50:13 ------------------------------------------------ +50 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:60:11 ------------------------------------------------ +60 | case prev: A => // warn: the type test for A cannot be checked at runtime + | ^ + | the type test for A cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` +-- [E092] Pattern Match Unchecked Warning: tests/warn/i4812.scala:96:11 ------------------------------------------------ +96 | case x: B => // warn: the type test for B cannot be checked at runtime + | ^ + | the type test for B cannot be checked at runtime because it's a local class + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i4812.scala b/tests/warn/i4812.scala similarity index 79% rename from tests/neg/i4812.scala rename to tests/warn/i4812.scala index c6f6dafc656c..520294491acd 100644 --- a/tests/neg/i4812.scala +++ b/tests/warn/i4812.scala @@ -1,11 +1,11 @@ -//> using options -Werror + object Test: var prev: Any = scala.compiletime.uninitialized def test[T](x: T): T = class A(val elem: (T, Boolean)) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.elem._1 case _ => prev = new A((x, true)) @@ -15,7 +15,7 @@ object Test: abstract class Parent(_elem: T) { def elem: T = _elem } class A extends Parent(x) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.elem case _ => prev = new A @@ -25,7 +25,7 @@ object Test: class Holder(val elem: T) class A(val holder: Holder) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.holder.elem case _ => prev = new A(new Holder(x)) @@ -35,7 +35,7 @@ object Test: class Holder(val elem: (Int, (Unit, (T, Boolean)))) class A { var holder: Holder = null } prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.holder.elem._2._2._1 case _ => val a = new A @@ -47,7 +47,7 @@ object Test: def test5(x: U): U = class A(val elem: U) prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.elem case _ => prev = new A(x) @@ -57,7 +57,7 @@ object Test: class A { var b: B = null } class B { var a: A = null; var elem: T = scala.compiletime.uninitialized } prev match - case prev: A => // error: the type test for A cannot be checked at runtime + case prev: A => // warn: the type test for A cannot be checked at runtime prev.b.elem case _ => val a = new A @@ -93,7 +93,7 @@ object Test: val methodCallId = System.nanoTime() class B(val id: Long) extends A prevA match - case x: B => // error: the type test for B cannot be checked at runtime + case x: B => // warn: the type test for B cannot be checked at runtime x.ensuring(x.id == methodCallId, s"Method call id $methodCallId != ${x.id}") case _ => val x = new B(methodCallId) @@ -116,4 +116,4 @@ object Test: def main(args: Array[String]): Unit = test(1) - val x: String = test("") // was: ClassCastException: java.lang.Integer cannot be cast to java.lang.String + val x: String = test("") // was: ClassCastException: java.lang.Integer cannot be cast to java.lang.String \ No newline at end of file diff --git a/tests/warn/i4936b.scala b/tests/warn/i4936b.scala new file mode 100644 index 000000000000..057c90545dbd --- /dev/null +++ b/tests/warn/i4936b.scala @@ -0,0 +1,3 @@ + + +final object Foo // warn diff --git a/tests/neg/i4986b.check b/tests/warn/i4986b.check similarity index 80% rename from tests/neg/i4986b.check rename to tests/warn/i4986b.check index db30dcba8003..f20b467a295d 100644 --- a/tests/neg/i4986b.check +++ b/tests/warn/i4986b.check @@ -1,40 +1,40 @@ --- [E158] Reference Error: tests/neg/i4986b.scala:5:65 ----------------------------------------------------------------- -5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:5:65 -------------------------------------------------------------- +5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // warn // warn | ^ | Invalid reference to a type variable `Too` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `Meh`. --- [E158] Reference Error: tests/neg/i4986b.scala:5:94 ----------------------------------------------------------------- -5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:5:94 -------------------------------------------------------------- +5 |@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // warn // warn | ^ | Invalid reference to a type variable `Elem` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `Meh`. --- [E158] Reference Error: tests/neg/i4986b.scala:8:71 ----------------------------------------------------------------- -8 |@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:8:71 -------------------------------------------------------------- +8 |@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // warn | ^ | Invalid reference to a type variable `Elem` found in the annotation argument. | The variable does not occur as a parameter in the scope of type `Meh2`. --- [E158] Reference Error: tests/neg/i4986b.scala:11:46 ---------------------------------------------------------------- -11 |class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:11:46 ------------------------------------------------------------- +11 |class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // warn | ^ | Invalid reference to a type variable `t` found in the annotation argument. | The variable does not occur as a parameter in the scope of the constructor of `C`. --- [E158] Reference Error: tests/neg/i4986b.scala:14:54 ---------------------------------------------------------------- -14 | def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:14:54 ------------------------------------------------------------- +14 | def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // warn | ^ | Invalid reference to a type variable `Uuh` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. --- [E158] Reference Error: tests/neg/i4986b.scala:20:73 ---------------------------------------------------------------- -20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:20:73 ------------------------------------------------------------- +20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn | ^ | Invalid reference to a type variable `XX` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. --- [E158] Reference Error: tests/neg/i4986b.scala:20:79 ---------------------------------------------------------------- -20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:20:79 ------------------------------------------------------------- +20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn | ^ | Invalid reference to a type variable `ZZ` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. --- [E158] Reference Error: tests/neg/i4986b.scala:20:86 ---------------------------------------------------------------- -20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error +-- [E158] Reference Warning: tests/warn/i4986b.scala:20:86 ------------------------------------------------------------- +20 | def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn | ^ | Invalid reference to a type variable `Nix` found in the annotation argument. | The variable does not occur as a parameter in the scope of method `m`. diff --git a/tests/neg/i4986b.scala b/tests/warn/i4986b.scala similarity index 75% rename from tests/neg/i4986b.scala rename to tests/warn/i4986b.scala index c726e40fd4d8..6f2a0885090b 100644 --- a/tests/neg/i4986b.scala +++ b/tests/warn/i4986b.scala @@ -1,22 +1,22 @@ -//> using options -Xfatal-warnings + import scala.annotation.implicitNotFound -@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // error // error +@implicitNotFound(msg = "Cannot construct a collection of type ${Too} with elements of type ${Elem} based on a collection of type ${From}.") // warn // warn trait Meh[-From, +To] -@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // error +@implicitNotFound(msg = "Cannot construct a collection of type ${To} ${Elem}.") // warn trait Meh2[-From, +To] -class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // error +class C[T](implicit @implicitNotFound("No C[${t}] available") t: T) // warn trait T { - def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // error + def m[Aaa](implicit @implicitNotFound("I see no C[${Uuh}]") theC: C[Aaa]) = ??? // warn def n[Aaa](implicit @implicitNotFound("I see no C[${Aaa}]") theC: C[Aaa]) = ??? } trait U[X, Y[_], Z[_, ZZ]] { class I[R] { - def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // error // error // error + def m[S](implicit @implicitNotFound("${X} ${Y} ${ Z } ${R} ${S} -- ${XX} ${ZZ} ${ Nix }") i: Int) = ??? // warn // warn // warn } -} +} \ No newline at end of file diff --git a/tests/warn/i5013.scala b/tests/warn/i5013.scala new file mode 100644 index 000000000000..9fbc32967b78 --- /dev/null +++ b/tests/warn/i5013.scala @@ -0,0 +1,11 @@ + + +class Foo { + + def foo1: Unit = 2 // warn: A pure expression does nothing in statement position + + def foo2: Unit = { + 3 // warn: A pure expression does nothing in statement position + 4 // warn: A pure expression does nothing in statement position + } +} \ No newline at end of file diff --git a/tests/neg/i5013b.scala b/tests/warn/i5013b.scala similarity index 62% rename from tests/neg/i5013b.scala rename to tests/warn/i5013b.scala index 7ccaf47c12f3..09ce319e0a88 100644 --- a/tests/neg/i5013b.scala +++ b/tests/warn/i5013b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + class Foo { @@ -11,8 +11,9 @@ class Foo { val c: Unit = () - def foo1: Unit = a // error: A pure expression does nothing in statement position + def foo1: Unit = a // warn: A pure expression does nothing in statement position def foo2: Unit = b def foo3: Unit = c // Not addapted to { c; () } and hence c is not a statement } + diff --git a/tests/neg/i5077.scala b/tests/warn/i5077.scala similarity index 89% rename from tests/neg/i5077.scala rename to tests/warn/i5077.scala index d705ffe52dd9..404b2cf5a639 100644 --- a/tests/neg/i5077.scala +++ b/tests/warn/i5077.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns trait Is[A] case object IsInt extends Is[Int] case object IsString extends Is[String] @@ -12,7 +12,7 @@ def Test = { // Case 1: error c_string match { - case C(IsInt, _) => println(s"An Int") // error + case C(IsInt, _) => println(s"An Int") // warn case C(IsString, s) => println(s"A String with length ${s.length}") case _ => println("No match") } diff --git a/tests/neg/i6190b.check b/tests/warn/i6190b.check similarity index 65% rename from tests/neg/i6190b.check rename to tests/warn/i6190b.check index 5d4dbd7c24cb..eecf7bbcf13e 100644 --- a/tests/neg/i6190b.check +++ b/tests/warn/i6190b.check @@ -1,4 +1,4 @@ --- Error: tests/neg/i6190b.scala:5:29 ---------------------------------------------------------------------------------- -5 |def foo = List("1", "2").map(Rule) // error +-- Warning: tests/warn/i6190b.scala:5:29 ------------------------------------------------------------------------------- +5 |def foo = List("1", "2").map(Rule) // warn | ^^^^ | The method `apply` is inserted. The auto insertion will be deprecated, please write `Rule.apply` explicitly. diff --git a/tests/warn/i6190b.scala b/tests/warn/i6190b.scala new file mode 100644 index 000000000000..a10006516c6f --- /dev/null +++ b/tests/warn/i6190b.scala @@ -0,0 +1,6 @@ + + +case class Rule(name: String) + +def foo = List("1", "2").map(Rule) // warn + diff --git a/tests/neg/i7314.scala b/tests/warn/i7314.scala similarity index 62% rename from tests/neg/i7314.scala rename to tests/warn/i7314.scala index b865f2ad881b..4d0d525542bf 100644 --- a/tests/neg/i7314.scala +++ b/tests/warn/i7314.scala @@ -1,11 +1,11 @@ -//> using options -Xfatal-warnings -source future +//> using options -source future @main def Test = // conversion out of the opaque type: val imm1 = IArray(1,2,3) // supposedly immutable println(imm1(0)) // 1 imm1 match { - case a: Array[Int] => // error: should not be scrutinized + case a: Array[Int] => // warn: should not be scrutinized a(0) = 0 } println(imm1(0)) // 0 diff --git a/tests/neg/i7821.scala b/tests/warn/i7821.scala similarity index 75% rename from tests/neg/i7821.scala rename to tests/warn/i7821.scala index 5275c06e487f..6ac46ef730bb 100644 --- a/tests/neg/i7821.scala +++ b/tests/warn/i7821.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + object XObject { opaque type X = Int @@ -16,7 +16,7 @@ object MyXObject { def anX: MyX = XObject.anX given ops: Object with { - extension (x: MyX) def + (y: MyX): MyX = x + y // error: warring: Infinite recursive call + extension (x: MyX) def + (y: MyX): MyX = x + y // warn: warring: Infinite recursive call } } diff --git a/tests/warn/i7821b.scala b/tests/warn/i7821b.scala new file mode 100644 index 000000000000..db3de3f86e2f --- /dev/null +++ b/tests/warn/i7821b.scala @@ -0,0 +1,13 @@ + + +object Test { + + { def f(x: Int, y: Int): Int = f(x, y) } // warn + { def f(x: Int, y: Int): Int = { f(x, y) } } // warn + { def f(x: Int, y: Int): Int = f(y, x) } // warn + { def f(x: Int, y: Int): Int = f(x, x) } // warn + { def f(x: Int, y: Int): Int = f(1, 1) } // warn + { def f(x: Int, y: Int): Int = { val a = 3; f(a, 1) } } // warn + { def f(x: Int): Int = f(1) } // warn + +} \ No newline at end of file diff --git a/tests/neg/i8427.scala b/tests/warn/i8427.scala similarity index 63% rename from tests/neg/i8427.scala rename to tests/warn/i8427.scala index 3db449bed41c..61ea2eabb79a 100644 --- a/tests/neg/i8427.scala +++ b/tests/warn/i8427.scala @@ -1,6 +1,6 @@ -//> using options -Xfatal-warnings -@SerialVersionUID(1L) // error + +@SerialVersionUID(1L) // warn trait T object Test { diff --git a/tests/warn/i8781b.scala b/tests/warn/i8781b.scala new file mode 100644 index 000000000000..455cd49b927a --- /dev/null +++ b/tests/warn/i8781b.scala @@ -0,0 +1,8 @@ + + +object Test: + + println((3: Boolean | Int).isInstanceOf[Boolean]) + + println(3.isInstanceOf[Boolean]) // warn + diff --git a/tests/neg/i8922b.scala b/tests/warn/i8922b.scala similarity index 97% rename from tests/neg/i8922b.scala rename to tests/warn/i8922b.scala index 9e615a8d5b58..f167eea005c5 100644 --- a/tests/neg/i8922b.scala +++ b/tests/warn/i8922b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + case class Token(tokenType: TokenType, lexeme: StringV, line: IntV) @@ -33,7 +33,7 @@ object Interpreter { case Binary(left, op, right) => val l = eval(left) val r = eval(right) - (l, r, op.tokenType) match { // error + (l, r, op.tokenType) match { // warn case (l: DoubleV, r: DoubleV, PLUS) => ??? case (l: IntV, r: IntV, PLUS) => ??? case (l: DoubleV, r: IntV, PLUS) => ??? @@ -75,4 +75,4 @@ object Interpreter { } } -} \ No newline at end of file +} diff --git a/tests/warn/i9166.scala b/tests/warn/i9166.scala new file mode 100644 index 000000000000..34a42987f6aa --- /dev/null +++ b/tests/warn/i9166.scala @@ -0,0 +1,8 @@ +//> using options -Wimplausible-patterns +object UnitTest extends App { + def foo(m: Unit) = m match { + case runtime.BoxedUnit.UNIT => println("ok") // warn + } + foo(()) +} + diff --git a/tests/neg/i9241.scala b/tests/warn/i9241.scala similarity index 64% rename from tests/neg/i9241.scala rename to tests/warn/i9241.scala index e7c959fc9ee2..ed1db2df0c8e 100644 --- a/tests/neg/i9241.scala +++ b/tests/warn/i9241.scala @@ -1,10 +1,10 @@ -//> using options -Xfatal-warnings + class Foo { - def unary_~() : Foo = this // error - def unary_-(using Int)(): Foo = this // error - def unary_+()(implicit i: Int): Foo = this // error - def unary_![T](): Foo = this // error + def unary_~() : Foo = this // warn + def unary_-(using Int)(): Foo = this // warn + def unary_+()(implicit i: Int): Foo = this // warn + def unary_![T](): Foo = this // warn } class Bar { @@ -17,27 +17,27 @@ class Bar { final class Baz private (val x: Int) extends AnyVal { def unary_- : Baz = ??? def unary_+[T] : Baz = ??? - def unary_!() : Baz = ??? // error + def unary_!() : Baz = ??? // warn def unary_~(using Int) : Baz = ??? } extension (x: Int) def unary_- : Int = ??? def unary_+[T] : Int = ??? - def unary_!() : Int = ??? // error + def unary_!() : Int = ??? // warn def unary_~(using Int) : Int = ??? end extension extension [T](x: Short) def unary_- : Int = ??? def unary_+[U] : Int = ??? - def unary_!() : Int = ??? // error + def unary_!() : Int = ??? // warn def unary_~(using Int) : Int = ??? end extension extension (using Int)(x: Byte) def unary_- : Int = ??? def unary_+[U] : Int = ??? - def unary_!() : Int = ??? // error + def unary_!() : Int = ??? // warn def unary_~(using Int) : Int = ??? -end extension +end extension \ No newline at end of file diff --git a/tests/neg/i9266.check b/tests/warn/i9266.check similarity index 71% rename from tests/neg/i9266.check rename to tests/warn/i9266.check index bd80a017da02..90dfe43bd2b2 100644 --- a/tests/neg/i9266.check +++ b/tests/warn/i9266.check @@ -1,5 +1,5 @@ --- Error: tests/neg/i9266.scala:5:22 ----------------------------------------------------------------------------------- -5 |def test = { implicit x: Int => x + x } // error +-- Migration Warning: tests/warn/i9266.scala:5:22 ---------------------------------------------------------------------- +5 |def test = { implicit x: Int => x + x } // warn | ^ | This syntax is no longer supported; parameter needs to be enclosed in (...) | This construct can be rewritten automatically under -rewrite -source future-migration. diff --git a/tests/warn/i9266.scala b/tests/warn/i9266.scala new file mode 100644 index 000000000000..c621e9e20b99 --- /dev/null +++ b/tests/warn/i9266.scala @@ -0,0 +1,6 @@ + + +import language.`future-migration` + +def test = { implicit x: Int => x + x } // warn + diff --git a/tests/neg/i9408a.check b/tests/warn/i9408a.check similarity index 76% rename from tests/neg/i9408a.check rename to tests/warn/i9408a.check index d9deb9cddaf7..ed2e94090cae 100644 --- a/tests/neg/i9408a.check +++ b/tests/warn/i9408a.check @@ -1,24 +1,24 @@ --- Error: tests/neg/i9408a.scala:18:20 --------------------------------------------------------------------------------- -18 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:18:20 -------------------------------------------------------------------- +18 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test3.implicitLength : String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:23:20 --------------------------------------------------------------------------------- -23 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:23:20 -------------------------------------------------------------------- +23 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test4.implicitLength : => String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:28:20 --------------------------------------------------------------------------------- -28 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:28:20 -------------------------------------------------------------------- +28 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test5.implicitLength : [A]: String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:33:20 --------------------------------------------------------------------------------- -33 | val length: Int = "qwerty" // error +-- Migration Warning: tests/warn/i9408a.scala:33:20 -------------------------------------------------------------------- +33 | val length: Int = "qwerty" // warn | ^^^^^^^^ |The conversion (Test6.implicitLength : Map[String, Int]) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:37:60 --------------------------------------------------------------------------------- -37 | implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // error +-- Migration Warning: tests/warn/i9408a.scala:37:60 -------------------------------------------------------------------- +37 | implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // warn | ^ |The conversion (ev : A => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. --- Error: tests/neg/i9408a.scala:61:2 ---------------------------------------------------------------------------------- -61 | 123.foo // error +-- Migration Warning: tests/warn/i9408a.scala:61:2 --------------------------------------------------------------------- +61 | 123.foo // warn | ^^^ |The conversion (Test11.a2foo : [A]: A => Test11.Foo) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views. diff --git a/tests/neg/i9408a.scala b/tests/warn/i9408a.scala similarity index 88% rename from tests/neg/i9408a.scala rename to tests/warn/i9408a.scala index 594417ec3215..64b58ff59550 100644 --- a/tests/neg/i9408a.scala +++ b/tests/warn/i9408a.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import language.`3.0-migration` import scala.language.implicitConversions @@ -15,26 +15,26 @@ object Test2 { object Test3 { implicit val implicitLength: String => Int = _.length - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test4 { implicit def implicitLength: String => Int = _.length - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test5 { implicit def implicitLength[A]: String => Int = _.length - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test6 { implicit val implicitLength: Map[String, Int] = Map("qwerty" -> 6) - val length: Int = "qwerty" // error + val length: Int = "qwerty" // warn } object Test7 { - implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // error + implicit def a2int[A](a: A)(implicit ev: A => Int): Int = a // warn } object Test8 { @@ -58,7 +58,7 @@ object Test11 { def foo = "foo" } implicit def a2foo[A]: A => Foo = _ => new Foo {} - 123.foo // error + 123.foo // warn } object Test12 { @@ -85,4 +85,4 @@ object Test15 { implicit def implicitSeq[A]: Seq[A] = ??? def foo(implicit ev: Seq[Int]): Unit = ??? foo -} +} \ No newline at end of file diff --git a/tests/neg/i9740.check b/tests/warn/i9740.check similarity index 76% rename from tests/neg/i9740.check rename to tests/warn/i9740.check index 359603a2863a..7d41bab8ec50 100644 --- a/tests/neg/i9740.check +++ b/tests/warn/i9740.check @@ -1,11 +1,11 @@ --- [E186] Type Error: tests/neg/i9740.scala:10:9 ----------------------------------------------------------------------- -10 | case RecoveryCompleted => println("Recovery completed") // error +-- [E186] Type Warning: tests/warn/i9740.scala:10:9 -------------------------------------------------------------------- +10 | case RecoveryCompleted => println("Recovery completed") // warn | ^^^^^^^^^^^^^^^^^ | Implausible pattern: | RecoveryCompleted could match selector of type object TypedRecoveryCompleted | only if there is an `equals` method identifying elements of the two types. --- [E186] Type Error: tests/neg/i9740.scala:15:9 ----------------------------------------------------------------------- -15 | case RecoveryCompleted => // error +-- [E186] Type Warning: tests/warn/i9740.scala:15:9 -------------------------------------------------------------------- +15 | case RecoveryCompleted => // warn | ^^^^^^^^^^^^^^^^^ | Implausible pattern: | RecoveryCompleted could match selector of type TypedRecoveryCompleted diff --git a/tests/neg/i9740.scala b/tests/warn/i9740.scala similarity index 78% rename from tests/neg/i9740.scala rename to tests/warn/i9740.scala index 6222298df48b..fc330df4d6a9 100644 --- a/tests/neg/i9740.scala +++ b/tests/warn/i9740.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns abstract class RecoveryCompleted object RecoveryCompleted extends RecoveryCompleted @@ -7,11 +7,11 @@ object TypedRecoveryCompleted extends TypedRecoveryCompleted class Test { TypedRecoveryCompleted match { - case RecoveryCompleted => println("Recovery completed") // error + case RecoveryCompleted => println("Recovery completed") // warn case TypedRecoveryCompleted => println("Typed recovery completed") } def foo(x: TypedRecoveryCompleted) = x match - case RecoveryCompleted => // error + case RecoveryCompleted => // warn case TypedRecoveryCompleted => -} +} \ No newline at end of file diff --git a/tests/neg/i9740b.scala b/tests/warn/i9740b.scala similarity index 75% rename from tests/neg/i9740b.scala rename to tests/warn/i9740b.scala index dcd9a1d6a474..632308e3322d 100644 --- a/tests/neg/i9740b.scala +++ b/tests/warn/i9740b.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns enum Recovery: case RecoveryCompleted @@ -10,11 +10,11 @@ import TypedRecovery.* class Test { TypedRecoveryCompleted match { - case RecoveryCompleted => println("Recovery completed") // error + case RecoveryCompleted => println("Recovery completed") // warn case TypedRecoveryCompleted => println("Typed recovery completed") } def foo(x: TypedRecovery) = x match - case RecoveryCompleted => // error + case RecoveryCompleted => // warn case TypedRecoveryCompleted => -} +} \ No newline at end of file diff --git a/tests/neg/i9740c.scala b/tests/warn/i9740c.scala similarity index 80% rename from tests/neg/i9740c.scala rename to tests/warn/i9740c.scala index c6a3a1380f1d..8ddf87adf46b 100644 --- a/tests/neg/i9740c.scala +++ b/tests/warn/i9740c.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns sealed trait Exp[T] case class IntExp(x: Int) extends Exp[Int] case class StrExp(x: String) extends Exp[String] @@ -12,6 +12,7 @@ class Foo { def bar[A <: Txn[A]](x: Exp[A]): Unit = x match case IntExp(x) => case StrExp(x) => - case UnitExp => // error + case UnitExp => // warn case Obj(o) => } + diff --git a/tests/neg/i9740d.scala b/tests/warn/i9740d.scala similarity index 67% rename from tests/neg/i9740d.scala rename to tests/warn/i9740d.scala index 6f3cc3be02e2..87c7dc264afa 100644 --- a/tests/neg/i9740d.scala +++ b/tests/warn/i9740d.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -Wimplausible-patterns +//> using options -Wimplausible-patterns sealed trait Exp[T] case class IntExp(x: Int) extends Exp[Int] @@ -8,6 +8,6 @@ object UnitExp extends Exp[Unit] class Foo[U <: Int, T <: U] { def bar[A <: T](x: Exp[A]): Unit = x match case IntExp(x) => - case StrExp(x) => - case UnitExp => // error + case StrExp(x) => // warn + case UnitExp => // warn implausible pattern } diff --git a/tests/warn/i9751.scala b/tests/warn/i9751.scala new file mode 100644 index 000000000000..284070723474 --- /dev/null +++ b/tests/warn/i9751.scala @@ -0,0 +1,11 @@ + + +def f(): Unit = { + () // warn + () +} + +inline def g(): Unit = { + () // warn + () +} \ No newline at end of file diff --git a/tests/neg/i9776.scala b/tests/warn/i9776.scala similarity index 84% rename from tests/neg/i9776.scala rename to tests/warn/i9776.scala index b05488810416..93b7cce98fef 100644 --- a/tests/neg/i9776.scala +++ b/tests/warn/i9776.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings + import scala.annotation.switch @@ -12,7 +12,7 @@ object Fruit { case object Orange extends Fruit def isCitrus(fruit: Fruit): Boolean = - (fruit: @switch) match { // error Could not emit switch for @switch annotated match + (fruit: @switch) match { // warn Could not emit switch for @switch annotated match case Orange => true case Lemon => true case Lime => true @@ -37,7 +37,7 @@ object TaggedFruit { } def isCitrus(fruit: TaggedFruit): Boolean = - (fruit.tag: @switch) match { // error Could not emit switch for @switch annotated match + (fruit.tag: @switch) match { // warn Could not emit switch for @switch annotated match case Apple.tag => true case 2 => true case 3 => true @@ -58,4 +58,4 @@ object TaggedFruit { case 2 => true case Apple.tag => true } -} +} \ No newline at end of file diff --git a/tests/neg/i9880.scala b/tests/warn/i9880.scala similarity index 81% rename from tests/neg/i9880.scala rename to tests/warn/i9880.scala index f99fae25e5dc..68775e7646a5 100644 --- a/tests/neg/i9880.scala +++ b/tests/warn/i9880.scala @@ -1,9 +1,9 @@ -//> using options -Xfatal-warnings + opaque type Bytes = Array[Byte] object Bytes: extension (self: Bytes) - def size: Int = (self: Array[Byte]).size // error + def size: Int = (self: Array[Byte]).size // warn // @@ -20,7 +20,7 @@ object Module2: object Gen: extension [A](self: Gen[A]) def map[B](f: A => B): Gen[B] = - self.map(f) // error + self.map(f) // warn // @@ -29,4 +29,4 @@ class Sym(val owner: Sym) extension (sym: Sym) def isSomething: Boolean = false def isFoo: Boolean = sym.isSomething && sym.owner.isFoo // was: Infinite loop in function body - def isBar: Boolean = sym.isSomething || sym.owner.isBar // was: Infinite loop in function body + def isBar: Boolean = sym.isSomething || sym.owner.isBar // was: Infinite loop in function body \ No newline at end of file diff --git a/tests/warn/implicit-conversions-old.scala b/tests/warn/implicit-conversions-old.scala new file mode 100644 index 000000000000..24e1124015e3 --- /dev/null +++ b/tests/warn/implicit-conversions-old.scala @@ -0,0 +1,25 @@ +//> using options -feature + +class A +class B + +object A { + + implicit def a2b(x: A): B = ??? // warn under -Xfatal-warnings -feature + + implicit def b2a(x: B): A = ??? // warn under -Xfatal-warnings -feature +} + +class C + +object D { + implicit def a2c(x: A): C = ??? // warn under -Xfatal-warnings -feature +} + +object Test { + import D.* + + val x1: A = new B + val x2: B = new A // ok, since it's an old-style comversion + val x3: C = new A // ok, since it's an old-style comversion +} \ No newline at end of file diff --git a/tests/neg/implicit-conversions.scala b/tests/warn/implicit-conversions.scala similarity index 55% rename from tests/neg/implicit-conversions.scala rename to tests/warn/implicit-conversions.scala index ead8c5ac7646..946d0c96fd5a 100644 --- a/tests/neg/implicit-conversions.scala +++ b/tests/warn/implicit-conversions.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -feature +//> using options -feature class A class B @@ -25,7 +25,7 @@ object D { object Test { import D.given - val x1: A = new B // error under -Xfatal-warnings -feature - val x2: B = new A // error under -Xfatal-warnings -feature - val x3: C = new A // error under -Xfatal-warnings -feature + val x1: A = new B // warn under -Xfatal-warnings -feature + val x2: B = new A // warn under -Xfatal-warnings -feature + val x3: C = new A // warn under -Xfatal-warnings -feature } \ No newline at end of file diff --git a/tests/neg/inline-givens.scala b/tests/warn/inline-givens.scala similarity index 57% rename from tests/neg/inline-givens.scala rename to tests/warn/inline-givens.scala index 3e388de2ce8b..5ab4fd65fdc9 100644 --- a/tests/neg/inline-givens.scala +++ b/tests/warn/inline-givens.scala @@ -1,16 +1,15 @@ -//> using options -Xfatal-warnings + class Item(x: String) inline given a: Conversion[String, Item] = - Item(_) // error + Item(_) // warn inline given b: Conversion[String, Item] = - (x => Item(x)) // error + (x => Item(x)) // warn inline given c: Conversion[String, Item] = - { x => Item(x) } // error + { x => Item(x) } // warn inline given d: Conversion[String, Item] with - def apply(x: String) = Item(x) // ok - + def apply(x: String) = Item(x) // ok \ No newline at end of file