From c471c78613ef09af87c69bac15bc3215fc7a6e1a Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Thu, 27 Jun 2024 14:42:50 +0200 Subject: [PATCH 1/2] Third batch of neg -> warn test changes [Cherry-picked 59b0b69426765041aab5f39e4df4070faf78dcef][modified] --- tests/neg-deep-subtype/i4297.scala | 13 ------ tests/neg-macros/i9570.check | 4 ++ tests/neg-macros/i9570.scala | 2 +- tests/neg-macros/macro-deprecation.check | 4 ++ tests/neg-macros/macro-deprecation.scala | 2 +- tests/neg-scalajs/enumeration-warnings.check | 49 ++++++++++---------- tests/neg-scalajs/enumeration-warnings.scala | 26 ++++++----- tests/patmat/i14407.dupe.check | 1 + tests/run/getclass.check | 4 +- 9 files changed, 52 insertions(+), 53 deletions(-) delete mode 100644 tests/neg-deep-subtype/i4297.scala create mode 100644 tests/neg-macros/i9570.check create mode 100644 tests/neg-macros/macro-deprecation.check diff --git a/tests/neg-deep-subtype/i4297.scala b/tests/neg-deep-subtype/i4297.scala deleted file mode 100644 index 9112de9de79b..000000000000 --- a/tests/neg-deep-subtype/i4297.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Xfatal-warnings - -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, _]] // error - def test3b(x: Any) = x.isInstanceOf[Function1[Int, _]] // error - def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, _]] // error - def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // error - def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // error - def test7[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[_, Unit]] -} diff --git a/tests/neg-macros/i9570.check b/tests/neg-macros/i9570.check new file mode 100644 index 000000000000..1e546c8cc485 --- /dev/null +++ b/tests/neg-macros/i9570.check @@ -0,0 +1,4 @@ +-- Error: tests/neg-macros/i9570.scala:15:21 --------------------------------------------------------------------------- +15 | case '{HCons(_,$t)} => // error + | ^ + | Use of `_` for lambda in quoted pattern. Use explicit lambda instead or use `$_` to match any term. diff --git a/tests/neg-macros/i9570.scala b/tests/neg-macros/i9570.scala index 9242fd2e9bbd..0ac78285355c 100644 --- a/tests/neg-macros/i9570.scala +++ b/tests/neg-macros/i9570.scala @@ -12,7 +12,7 @@ object Macros { private def sizeImpl(e: Expr[HList], n:Int)(using qctx:Quotes): Expr[Int] = { import quotes.reflect.* e match { - case '{HCons(_,$t)} => // error if run with fatal warinings in BootstrappedOnlyCompilationTests + case '{HCons(_,$t)} => // error sizeImpl(t,n+1) case '{HNil} => Expr(n) } diff --git a/tests/neg-macros/macro-deprecation.check b/tests/neg-macros/macro-deprecation.check new file mode 100644 index 000000000000..eaea18315e92 --- /dev/null +++ b/tests/neg-macros/macro-deprecation.check @@ -0,0 +1,4 @@ +-- Error: tests/neg-macros/macro-deprecation.scala:5:18 ---------------------------------------------------------------- +5 |inline def f = ${ impl } // error + | ^^^^ + | method impl is deprecated diff --git a/tests/neg-macros/macro-deprecation.scala b/tests/neg-macros/macro-deprecation.scala index ad1cdda001bb..ffa146ef361c 100644 --- a/tests/neg-macros/macro-deprecation.scala +++ b/tests/neg-macros/macro-deprecation.scala @@ -3,4 +3,4 @@ import scala.quoted.* inline def f = ${ impl } // error -@deprecated def impl(using Quotes) = '{1} +@deprecated def impl(using Quotes) = '{1} \ No newline at end of file diff --git a/tests/neg-scalajs/enumeration-warnings.check b/tests/neg-scalajs/enumeration-warnings.check index b356a150daa5..5d791be5928a 100644 --- a/tests/neg-scalajs/enumeration-warnings.check +++ b/tests/neg-scalajs/enumeration-warnings.check @@ -1,60 +1,61 @@ --- Error: tests/neg-scalajs/enumeration-warnings.scala:6:4 ------------------------------------------------------------- -6 | Value // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:6:4 ----------------------------------------------------------- +6 | Value // warn | ^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Error: tests/neg-scalajs/enumeration-warnings.scala:10:9 ------------------------------------------------------------ -10 | Value(4) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:10:9 ---------------------------------------------------------- +10 | Value(4) // warn | ^^^^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Error: tests/neg-scalajs/enumeration-warnings.scala:15:15 ----------------------------------------------------------- -15 | val a = Value(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:15:15 --------------------------------------------------------- +15 | val a = Value(null) // warn | ^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:16:15 ----------------------------------------------------------- -16 | val b = Value(10, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:16:15 --------------------------------------------------------- +16 | val b = Value(10, null) // warn | ^^^^^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:20:10 ----------------------------------------------------------- -20 | val a = new Val // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:20:10 --------------------------------------------------------- +20 | val a = new Val // warn | ^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:21:10 ----------------------------------------------------------- -21 | val b = new Val(10) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:21:10 --------------------------------------------------------- +21 | val b = new Val(10) // warn | ^^^^^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:25:10 ----------------------------------------------------------- -25 | val a = new Val(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:25:10 --------------------------------------------------------- +25 | val a = new Val(null) // warn | ^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:26:10 ----------------------------------------------------------- -26 | val b = new Val(10, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:26:10 --------------------------------------------------------- +26 | val b = new Val(10, null) // warn | ^^^^^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:30:31 ----------------------------------------------------------- -30 | protected class Val1 extends Val // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:30:31 --------------------------------------------------------- +30 | protected class Val1 extends Val // warn | ^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:31:31 ----------------------------------------------------------- -31 | protected class Val2 extends Val(1) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:31:31 --------------------------------------------------------- +31 | protected class Val2 extends Val(1) // warn | ^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:35:31 ----------------------------------------------------------- -35 | protected class Val1 extends Val(null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:35:31 --------------------------------------------------------- +35 | protected class Val1 extends Val(null) // warn | ^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Error: tests/neg-scalajs/enumeration-warnings.scala:36:31 ----------------------------------------------------------- -36 | protected class Val2 extends Val(1, null) // error +-- Warning: tests/neg-scalajs/enumeration-warnings.scala:36:31 --------------------------------------------------------- +36 | protected class Val2 extends Val(1, null) // warn | ^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. +No warnings can be incurred under -Werror. diff --git a/tests/neg-scalajs/enumeration-warnings.scala b/tests/neg-scalajs/enumeration-warnings.scala index b48ffc9500e3..10536fef4ba6 100644 --- a/tests/neg-scalajs/enumeration-warnings.scala +++ b/tests/neg-scalajs/enumeration-warnings.scala @@ -3,35 +3,37 @@ class UnableToTransformValue extends Enumeration { val a = { println("oh, oh!") - Value // error + Value // warn } val b = { println("oh, oh!") - Value(4) // error + Value(4) // warn } } class ValueWithNullName extends Enumeration { - val a = Value(null) // error - val b = Value(10, null) // error + val a = Value(null) // warn + val b = Value(10, null) // warn } class NewValWithNoName extends Enumeration { - val a = new Val // error - val b = new Val(10) // error + val a = new Val // warn + val b = new Val(10) // warn } class NewValWithNullName extends Enumeration { - val a = new Val(null) // error - val b = new Val(10, null) // error + val a = new Val(null) // warn + val b = new Val(10, null) // warn } class ExtendsValWithNoName extends Enumeration { - protected class Val1 extends Val // error - protected class Val2 extends Val(1) // error + protected class Val1 extends Val // warn + protected class Val2 extends Val(1) // warn } class ExtendsValWithNullName extends Enumeration { - protected class Val1 extends Val(null) // error - protected class Val2 extends Val(1, null) // error + protected class Val1 extends Val(null) // warn + protected class Val2 extends Val(1, null) // warn } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/patmat/i14407.dupe.check b/tests/patmat/i14407.dupe.check index b0605bcd95e5..e6f742314d98 100644 --- a/tests/patmat/i14407.dupe.check +++ b/tests/patmat/i14407.dupe.check @@ -1 +1,2 @@ 6: Match case Unreachable +0: No Kind diff --git a/tests/run/getclass.check b/tests/run/getclass.check index ea73f6127c8f..f5f412ab2edc 100644 --- a/tests/run/getclass.check +++ b/tests/run/getclass.check @@ -22,5 +22,5 @@ class [D class [Lscala.collection.immutable.List; Functions: -class Test$$$Lambda$ -class Test$$$Lambda$ +class Test$$$Lambda/ +class Test$$$Lambda/ From 523b2c51bbe174d0a4bc09a138fe619ca05f65a5 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Thu, 27 Jun 2024 14:51:22 +0200 Subject: [PATCH 2/2] Fix tests after rebase [Cherry-picked bfe0c702795833d7877b145b581cc84f3a39d8d4][modified] --- tests/neg-scalajs/enumeration-warnings.check | 49 ++++++++++---------- tests/neg-scalajs/enumeration-warnings.scala | 26 +++++------ tests/patmat/i14407.dupe.check | 1 - tests/run/getclass.check | 4 +- 4 files changed, 38 insertions(+), 42 deletions(-) diff --git a/tests/neg-scalajs/enumeration-warnings.check b/tests/neg-scalajs/enumeration-warnings.check index 5d791be5928a..b356a150daa5 100644 --- a/tests/neg-scalajs/enumeration-warnings.check +++ b/tests/neg-scalajs/enumeration-warnings.check @@ -1,61 +1,60 @@ --- Warning: tests/neg-scalajs/enumeration-warnings.scala:6:4 ----------------------------------------------------------- -6 | Value // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:6:4 ------------------------------------------------------------- +6 | Value // error | ^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:10:9 ---------------------------------------------------------- -10 | Value(4) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:10:9 ------------------------------------------------------------ +10 | Value(4) // error | ^^^^^^^^ | Could not transform call to scala.Enumeration.Value. | The resulting program is unlikely to function properly as this operation requires reflection. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:15:15 --------------------------------------------------------- -15 | val a = Value(null) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:15:15 ----------------------------------------------------------- +15 | val a = Value(null) // error | ^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:16:15 --------------------------------------------------------- -16 | val b = Value(10, null) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:16:15 ----------------------------------------------------------- +16 | val b = Value(10, null) // error | ^^^^^^^^^^^^^^^ | Passing null as name to scala.Enumeration.Value requires reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:20:10 --------------------------------------------------------- -20 | val a = new Val // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:20:10 ----------------------------------------------------------- +20 | val a = new Val // error | ^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:21:10 --------------------------------------------------------- -21 | val b = new Val(10) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:21:10 ----------------------------------------------------------- +21 | val b = new Val(10) // error | ^^^^^^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:25:10 --------------------------------------------------------- -25 | val a = new Val(null) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:25:10 ----------------------------------------------------------- +25 | val a = new Val(null) // error | ^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:26:10 --------------------------------------------------------- -26 | val b = new Val(10, null) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:26:10 ----------------------------------------------------------- +26 | val b = new Val(10, null) // error | ^^^^^^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:30:31 --------------------------------------------------------- -30 | protected class Val1 extends Val // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:30:31 ----------------------------------------------------------- +30 | protected class Val1 extends Val // error | ^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:31:31 --------------------------------------------------------- -31 | protected class Val2 extends Val(1) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:31:31 ----------------------------------------------------------- +31 | protected class Val2 extends Val(1) // error | ^^^^^^ | Calls to the non-string constructors of scala.Enumeration.Val require reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:35:31 --------------------------------------------------------- -35 | protected class Val1 extends Val(null) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:35:31 ----------------------------------------------------------- +35 | protected class Val1 extends Val(null) // error | ^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. --- Warning: tests/neg-scalajs/enumeration-warnings.scala:36:31 --------------------------------------------------------- -36 | protected class Val2 extends Val(1, null) // warn +-- Error: tests/neg-scalajs/enumeration-warnings.scala:36:31 ----------------------------------------------------------- +36 | protected class Val2 extends Val(1, null) // error | ^^^^^^^^^^^^ | Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time. | The resulting program is unlikely to function properly. -No warnings can be incurred under -Werror. diff --git a/tests/neg-scalajs/enumeration-warnings.scala b/tests/neg-scalajs/enumeration-warnings.scala index 10536fef4ba6..b48ffc9500e3 100644 --- a/tests/neg-scalajs/enumeration-warnings.scala +++ b/tests/neg-scalajs/enumeration-warnings.scala @@ -3,37 +3,35 @@ class UnableToTransformValue extends Enumeration { val a = { println("oh, oh!") - Value // warn + Value // error } val b = { println("oh, oh!") - Value(4) // warn + Value(4) // error } } class ValueWithNullName extends Enumeration { - val a = Value(null) // warn - val b = Value(10, null) // warn + val a = Value(null) // error + val b = Value(10, null) // error } class NewValWithNoName extends Enumeration { - val a = new Val // warn - val b = new Val(10) // warn + val a = new Val // error + val b = new Val(10) // error } class NewValWithNullName extends Enumeration { - val a = new Val(null) // warn - val b = new Val(10, null) // warn + val a = new Val(null) // error + val b = new Val(10, null) // error } class ExtendsValWithNoName extends Enumeration { - protected class Val1 extends Val // warn - protected class Val2 extends Val(1) // warn + protected class Val1 extends Val // error + protected class Val2 extends Val(1) // error } class ExtendsValWithNullName extends Enumeration { - protected class Val1 extends Val(null) // warn - protected class Val2 extends Val(1, null) // warn + protected class Val1 extends Val(null) // error + protected class Val2 extends Val(1, null) // error } - -// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/patmat/i14407.dupe.check b/tests/patmat/i14407.dupe.check index e6f742314d98..b0605bcd95e5 100644 --- a/tests/patmat/i14407.dupe.check +++ b/tests/patmat/i14407.dupe.check @@ -1,2 +1 @@ 6: Match case Unreachable -0: No Kind diff --git a/tests/run/getclass.check b/tests/run/getclass.check index f5f412ab2edc..ea73f6127c8f 100644 --- a/tests/run/getclass.check +++ b/tests/run/getclass.check @@ -22,5 +22,5 @@ class [D class [Lscala.collection.immutable.List; Functions: -class Test$$$Lambda/ -class Test$$$Lambda/ +class Test$$$Lambda$ +class Test$$$Lambda$