From dd9808af7dd4ae5e91a93d6e16ddde4897261f23 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Thu, 2 Nov 2023 19:59:23 +0100 Subject: [PATCH] Adjusted tests --- tests/neg-deep-subtype/1828.scala | 4 +- tests/neg-deep-subtype/3324b.scala | 9 ++-- tests/neg-deep-subtype/3324f.scala | 7 +-- tests/neg-deep-subtype/3324g.scala | 5 +- tests/neg-deep-subtype/JavaSeqLiteral.scala | 6 ++- .../conditionalWarnings.scala | 5 +- tests/neg-deep-subtype/gadt.scala | 6 ++- tests/neg-deep-subtype/html.scala | 4 +- tests/neg-deep-subtype/i3324.scala | 4 +- tests/neg-deep-subtype/i4297.scala | 11 ++-- tests/neg-deep-subtype/or-type-trees.scala | 9 ++-- tests/neg-deep-subtype/refined-types.scala | 9 ++-- tests/neg-deep-subtype/t2755.scala | 5 +- tests/neg-deep-subtype/type-lambda.scala | 4 +- tests/neg/14034b.scala | 17 +++--- tests/neg/15981.check | 5 +- tests/neg/15981.scala | 3 +- tests/neg/17284.check | 13 ++--- tests/neg/17284.scala | 7 +-- tests/neg/18493.check | 9 ++-- tests/neg/18493.scala | 7 +-- tests/neg/IsInstanceOfClassTag2.scala | 4 +- tests/neg/adhoc-extension/B.scala | 11 ++-- tests/neg/avoid-warn-deprecation.scala | 3 +- tests/neg/capt-wf.scala | 11 ++-- .../neg/classtag-typetest/3_1-migration.scala | 3 +- tests/neg/classtag-typetest/3_1.scala | 3 +- tests/neg/convertible.scala | 10 ++-- tests/neg/deprecated-override.scala | 6 +-- tests/neg/feature-shadowing.scala | 3 +- tests/neg/filtering-fors.scala | 21 ++++---- tests/neg/gadt-contradictory-pattern.scala | 3 +- tests/neg/i10247.scala | 9 ++-- tests/neg/i10930.scala | 9 ++-- tests/neg/i10994.scala | 4 +- tests/neg/i11022.check | 21 ++++---- tests/neg/i11022.scala | 7 +-- tests/neg/i11097.scala | 7 +-- tests/neg/i11225b.scala | 4 +- tests/neg/i11333.check | 25 ++++----- tests/neg/i11333.scala | 13 ++--- tests/neg/i11344.scala | 4 +- tests/neg/i11963a.scala | 4 +- tests/neg/i11963b.scala | 4 +- tests/neg/i11963c.scala | 4 +- tests/neg/i12188/Test.scala | 6 ++- tests/neg/i12253.check | 9 ++-- tests/neg/i12253.scala | 5 +- tests/neg/i12597.scala | 4 +- tests/neg/i13011.scala | 11 ++-- tests/neg/i13440.check | 13 ++--- tests/neg/i13440.scala | 7 +-- tests/neg/i13542.scala | 14 ++--- tests/neg/i13946/BadPrinter.scala | 3 +- tests/neg/i14386.scala | 5 +- tests/neg/i14705.scala | 4 +- tests/neg/i14721.scala | 4 +- tests/neg/i15474.scala | 7 +-- tests/neg/i15479.scala | 6 ++- tests/neg/i15503-scala2/scala2-t11681.scala | 8 +-- tests/neg/i15503a.scala | 47 +++++++++-------- tests/neg/i15503b.scala | 45 ++++++++-------- tests/neg/i15503c.scala | 17 +++--- tests/neg/i15503d.scala | 9 ++-- tests/neg/i15503e.scala | 12 ++--- tests/neg/i15503f.scala | 4 +- tests/neg/i15503g.scala | 7 +-- tests/neg/i15503h.scala | 13 ++--- tests/neg/i15503i.scala | 47 +++++++++-------- tests/neg/i15503j.scala | 7 +-- tests/neg/i15662.scala | 4 +- tests/neg/i15893.scala | 19 +++---- tests/neg/i16639a.scala | 52 +++++++++---------- tests/neg/i16649-refutable.check | 5 +- tests/neg/i16649-refutable.scala | 4 +- tests/neg/i16728.check | 5 +- tests/neg/i16728.scala | 6 ++- tests/neg/i16876/Test.scala | 5 +- tests/neg/i16930.scala | 5 +- tests/neg/i17266.check | 37 ++++++------- tests/neg/i17266.scala | 19 +++---- tests/neg/i17314b.scala | 4 +- tests/neg/i17612a.check | 33 ++++++------ tests/neg/i17612a.scala | 13 ++--- tests/neg/i17612b.check | 33 ++++++------ tests/neg/i17612b/i17612b.scala | 11 ++-- tests/neg/i17613a.check | 29 ++++++----- tests/neg/i17613a.scala | 15 +++--- tests/neg/i17613b/i17613b.scala | 33 ++++++------ tests/neg/i18722.check | 17 +++--- tests/neg/i18722.scala | 9 ++-- tests/neg/i2333.scala | 7 +-- tests/neg/i2673.scala | 4 +- tests/neg/i2673b.scala | 4 +- tests/neg/i2673c.scala | 4 +- tests/neg/i3561.scala | 5 +- tests/neg/i4008.check | 33 ++++++------ tests/neg/i4008.scala | 17 +++--- tests/neg/i4364.scala | 4 +- tests/neg/i4812.check | 29 ++++++----- tests/neg/i4812.scala | 15 +++--- tests/neg/i4936b.scala | 4 +- tests/neg/i4986b.check | 33 ++++++------ tests/neg/i4986b.scala | 11 ++-- tests/neg/i4986d.scala | 5 +- tests/neg/i5013.scala | 7 +-- tests/neg/i5013b.scala | 4 +- tests/neg/i5077.scala | 5 +- tests/neg/i6190b.check | 5 +- tests/neg/i6190b.scala | 4 +- tests/neg/i7314.scala | 4 +- tests/neg/i7821.scala | 3 +- tests/neg/i7821b.scala | 15 +++--- tests/neg/i8427.scala | 3 +- tests/neg/i8681.scala | 3 +- tests/neg/i8711.check | 17 ++++-- tests/neg/i8711.scala | 4 +- tests/neg/i8781b.scala | 4 +- tests/neg/i8922b.scala | 6 ++- tests/neg/i9166.scala | 4 +- tests/neg/i9241.scala | 17 +++--- tests/neg/i9266.check | 5 +- tests/neg/i9266.scala | 4 +- tests/neg/i9408a.check | 25 ++++----- tests/neg/i9408a.scala | 13 ++--- tests/neg/i9408b.check | 5 +- tests/neg/i9408b/Test_2.scala | 4 +- tests/neg/i9740.check | 9 ++-- tests/neg/i9740.scala | 5 +- tests/neg/i9740b.scala | 5 +- tests/neg/i9740c.scala | 4 +- tests/neg/i9740d.scala | 3 +- tests/neg/i9751.scala | 5 +- tests/neg/i9776.scala | 5 +- tests/neg/i9880.scala | 5 +- tests/neg/impl-conv/A.scala | 2 +- tests/neg/impl-conv/B.scala | 3 +- tests/neg/implicit-conversions-old.scala | 9 ++-- tests/neg/implicit-conversions.scala | 9 ++-- tests/neg/indentLeft.scala | 3 +- tests/neg/indentRight.scala | 14 ++--- tests/neg/infix.scala | 11 ++-- tests/neg/inline-givens.scala | 8 +-- tests/neg/main-functions-nameclash.scala | 4 +- tests/neg/manifest-summoning-b.check | 9 ++-- tests/neg/manifest-summoning-b.scala | 5 +- tests/neg/matchable.scala | 14 ++--- tests/neg/missing-targetName.scala | 7 +-- tests/neg/newline-braces.scala | 4 +- tests/neg/nonunit-statement.scala | 41 ++++++++------- tests/neg/old-syntax.scala | 5 +- tests/neg/opaque-match.scala | 13 ++--- tests/neg/ovlazy.scala | 4 +- tests/neg/pureStatement.scala | 11 ++-- tests/neg/quote-simple-hole.scala | 5 +- tests/neg/refinements-this.scala | 4 +- .../refutable-pattern-binding-messages.check | 25 ++++----- .../refutable-pattern-binding-messages.scala | 13 ++--- tests/neg/rewrite-messages.check | 9 ++-- tests/neg/rewrite-messages.scala | 5 +- tests/neg/strict-pattern-bindings-3.2.scala | 33 ++++++------ tests/neg/structural-2.scala | 3 +- tests/neg/supertraits-b.scala | 11 ++-- tests/neg/switches.scala | 13 ++--- tests/neg/symbolic-packages.check | 17 +++--- tests/neg/symbolic-packages.scala | 7 +-- tests/neg/t3235-minimal.check | 17 +++--- tests/neg/t3235-minimal.scala | 9 ++-- tests/neg/t5830.scala | 4 +- tests/neg/type-test-paths-2.scala | 9 ++-- tests/neg/type-test-paths.scala | 4 +- tests/neg/type-test-syntesize-b.scala | 7 +-- tests/neg/unchecked-patterns.scala | 17 +++--- tests/neg/warn-value-discard.check | 21 ++++---- tests/neg/warn-value-discard.scala | 11 ++-- .../with-type-operator-future-migration.check | 5 +- .../with-type-operator-future-migration.scala | 4 +- tests/neg/xfatalWarnings.scala | 5 +- 178 files changed, 1020 insertions(+), 805 deletions(-) diff --git a/tests/neg-deep-subtype/1828.scala b/tests/neg-deep-subtype/1828.scala index ae228a83e898..9cab8e76e832 100644 --- a/tests/neg-deep-subtype/1828.scala +++ b/tests/neg-deep-subtype/1828.scala @@ -2,10 +2,12 @@ class Test { def remove[S](a: S | Int, f: Int => S):S = a match { - case a: S => a // error + case a: S => a // warn case a: Int => f(a) } val t: Int | String = 5 val t1 = remove[String](t, _.toString) } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/3324b.scala b/tests/neg-deep-subtype/3324b.scala index df0cc5432eff..71ffde73fbdc 100644 --- a/tests/neg-deep-subtype/3324b.scala +++ b/tests/neg-deep-subtype/3324b.scala @@ -2,10 +2,11 @@ class C[T] { val x: Any = ??? - if (x.isInstanceOf[List[String]]) // error: unchecked - if (x.isInstanceOf[T]) // error: unchecked + if (x.isInstanceOf[List[String]]) // warn: unchecked + if (x.isInstanceOf[T]) // warn: unchecked x match { - case x: List[String] => // error: unchecked - case x: T => // error: unchecked + case x: List[String] => // warn: unchecked + case x: T => // warn: unchecked } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/3324f.scala b/tests/neg-deep-subtype/3324f.scala index 445da5cb25a0..e73bd0d05eed 100644 --- a/tests/neg-deep-subtype/3324f.scala +++ b/tests/neg-deep-subtype/3324f.scala @@ -5,7 +5,8 @@ class D[T] class Test { def foo[T](x: C[T]) = x match { - case _: D[T] => // error - case _: C[Int] => // error + case _: D[T] => // warn + case _: C[Int] => // warn } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/3324g.scala b/tests/neg-deep-subtype/3324g.scala index a5b842e4e450..cd1fc660bed8 100644 --- a/tests/neg-deep-subtype/3324g.scala +++ b/tests/neg-deep-subtype/3324g.scala @@ -6,7 +6,7 @@ class Test { class C[T] extends B[Any] with A[T] def foo[T](c: C[T]): Unit = c match { - case _: B[T] => // error + case _: B[T] => // warn } def bar[T](b: B[T]): Unit = b match { @@ -14,8 +14,9 @@ class Test { } def quux[T](a: A[T]): Unit = a match { - case _: B[T] => // error!! + case _: B[T] => // warn!! } quux(new C[Int]) } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/JavaSeqLiteral.scala b/tests/neg-deep-subtype/JavaSeqLiteral.scala index 6003731ae657..863b4f436f89 100644 --- a/tests/neg-deep-subtype/JavaSeqLiteral.scala +++ b/tests/neg-deep-subtype/JavaSeqLiteral.scala @@ -10,7 +10,7 @@ object Test1 { class DummyTree extends JavaSeqLiteral[Any] def foo1(tree: Tree[Type]) = - tree.isInstanceOf[JavaSeqLiteral[Type]] // error + tree.isInstanceOf[JavaSeqLiteral[Type]] // warn foo1(new DummyTree) } @@ -28,4 +28,6 @@ object Test2 { tree.isInstanceOf[JavaSeqLiteral[Type]] foo1(new DummyTree) -} \ No newline at end of file +} + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/conditionalWarnings.scala b/tests/neg-deep-subtype/conditionalWarnings.scala index c4757cbb7546..c818b70b8ee5 100644 --- a/tests/neg-deep-subtype/conditionalWarnings.scala +++ b/tests/neg-deep-subtype/conditionalWarnings.scala @@ -5,11 +5,12 @@ object Test { given Conversion[String, Int] = _.length - foo // error + foo // warn val x: Int = "abc" // OK, since -feature warnings are not enabled. // The program compiles with final line // there was 1 feature warning; re-run with -feature for details - // nopos-error + // nopos-warn } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/gadt.scala b/tests/neg-deep-subtype/gadt.scala index 661c04fef373..ec59ca53572c 100644 --- a/tests/neg-deep-subtype/gadt.scala +++ b/tests/neg-deep-subtype/gadt.scala @@ -8,8 +8,10 @@ class Test { class D extends C def quux(a: A[C]): Unit = a match { - case _: B[C] => // error!! + case _: B[C] => // warn } quux(new B[D]) -} \ No newline at end of file +} + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/html.scala b/tests/neg-deep-subtype/html.scala index f17cfb661505..4257859e7156 100644 --- a/tests/neg-deep-subtype/html.scala +++ b/tests/neg-deep-subtype/html.scala @@ -12,9 +12,11 @@ object HTML: attrs.filter(_ != Nil).foreach{ case s: Seq[AppliedAttr] => s.foreach(sb.append(" ").append) - case s: Seq[Int] => // error + case s: Seq[Int] => // warn case e: AppliedAttr => sb.append(" ").append(e) } sb } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/i3324.scala b/tests/neg-deep-subtype/i3324.scala index 9b1060836430..154f0e5eb64d 100644 --- a/tests/neg-deep-subtype/i3324.scala +++ b/tests/neg-deep-subtype/i3324.scala @@ -2,5 +2,7 @@ class Foo { def foo(x: Any): Boolean = - x.isInstanceOf[List[String]] // error + x.isInstanceOf[List[String]] // warn } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/i4297.scala b/tests/neg-deep-subtype/i4297.scala index 9112de9de79b..3fcb427c246e 100644 --- a/tests/neg-deep-subtype/i4297.scala +++ b/tests/neg-deep-subtype/i4297.scala @@ -4,10 +4,11 @@ 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 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]] } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/or-type-trees.scala b/tests/neg-deep-subtype/or-type-trees.scala index ad86bf20e2a3..4e74df3cea4e 100644 --- a/tests/neg-deep-subtype/or-type-trees.scala +++ b/tests/neg-deep-subtype/or-type-trees.scala @@ -9,7 +9,7 @@ object Test1 { def foo2(myTree: Tree | (Context => Tree)) = myTree match - case treeFn: (Context => Tree) => // error + case treeFn: (Context => Tree) => // warn case _ => def foo3(myTree: Tree | (Context => Tree)) = @@ -25,16 +25,17 @@ object Test2 { trait Type def foo1(myTree: Tree[Type] | (Context => Tree[Type])) = - println(myTree.isInstanceOf[Tree[Type]]) // error + println(myTree.isInstanceOf[Tree[Type]]) // warn /* class DummyTree extends Tree[Nothing] with (Context => Tree[Type]) */ def foo2(myTree: Tree[Type] | (Context => Tree[Type])) = myTree match - case treeFn: (Context => Tree[Type]) => // error + case treeFn: (Context => Tree[Type]) => // warn case _ => def foo3(myTree: Tree[Type] | (Context => Tree[Type])) = myTree match case treeFn: (_ => _) => // ok case _ => -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/refined-types.scala b/tests/neg-deep-subtype/refined-types.scala index 5f5cc5a45f04..0e76ff58515f 100644 --- a/tests/neg-deep-subtype/refined-types.scala +++ b/tests/neg-deep-subtype/refined-types.scala @@ -18,7 +18,8 @@ def bl(x: AA) = x.isInstanceOf[BL] // was: the type test for BL cannot be checke def bu(x: AA) = x.isInstanceOf[BU] // was: the type test for BU cannot be checked at runtime // but static knowledge of only one bound makes checking against an alias unchecked: -def al_ba(x: AL) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime -def au_ba(x: AU) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime -def al_bu(x: AL) = x.isInstanceOf[BU] // error: the type test for BU cannot be checked at runtime -def au_bl(x: AU) = x.isInstanceOf[BL] // error: the type test for BL cannot be checked at runtime +def al_ba(x: AL) = x.isInstanceOf[BA] // warn: the type test for BA cannot be checked at runtime +def au_ba(x: AU) = x.isInstanceOf[BA] // warn: the type test for BA cannot be checked at runtime +def al_bu(x: AL) = x.isInstanceOf[BU] // warn: the type test for BU cannot be checked at runtime +def au_bl(x: AU) = x.isInstanceOf[BL] // warn: the type test for BL cannot be checked at runtime +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/t2755.scala b/tests/neg-deep-subtype/t2755.scala index a8d888f3a821..698b59a57efd 100644 --- a/tests/neg-deep-subtype/t2755.scala +++ b/tests/neg-deep-subtype/t2755.scala @@ -19,7 +19,7 @@ object Test { case x: Array[String] => x.size case x: Array[AnyRef] => 5 case x: Array[_] => 6 - case _ => 7 // error: only null is matched + case _ => 7 // warn: only null is matched } def f3[T](a: Array[T]) = a match { case x: Array[Int] => x(0) @@ -28,7 +28,7 @@ object Test { case x: Array[String] => x.size case x: Array[AnyRef] => 5 case x: Array[_] => 6 - case _ => 7 // error: only null is matched + case _ => 7 // warn: only null is matched } @@ -58,3 +58,4 @@ object Test { println(f3(null)) } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg-deep-subtype/type-lambda.scala b/tests/neg-deep-subtype/type-lambda.scala index 4c4627fe1cf3..9e1b1b408f7c 100644 --- a/tests/neg-deep-subtype/type-lambda.scala +++ b/tests/neg-deep-subtype/type-lambda.scala @@ -10,7 +10,9 @@ object Test { } def bar(x: ([X] =>> A[X])[Any]) = x match { - case x: ([X] =>> B[Nothing])[Any] => // error + case x: ([X] =>> B[Nothing])[Any] => // warn case _ => } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/14034b.scala b/tests/neg/14034b.scala index 84f9ab3579c8..7f9f4e8f1cac 100644 --- a/tests/neg/14034b.scala +++ b/tests/neg/14034b.scala @@ -3,13 +3,14 @@ @deprecated trait Exp @deprecated val exp = 1 -def test1 = exp // error -def test2(a: Exp) = () // error +def test1 = exp // warn +def test2(a: Exp) = () // warn -type Foo0 = Exp // error -type Foo = Option[Exp] // error -type Bar = Option[exp.type] // error -type Baz = Exp | Int // error +type Foo0 = Exp // warn +type Foo = Option[Exp] // warn +type Bar = Option[exp.type] // warn +type Baz = Exp | Int // warn type Quux = [X] =>> X match - case Exp => Int // error -type Quuz[A <: Exp] = Int // error + case Exp => Int // warn +type Quuz[A <: Exp] = Int // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/15981.check b/tests/neg/15981.check index 10745839c566..d1cac67d2024 100644 --- a/tests/neg/15981.check +++ b/tests/neg/15981.check @@ -1,6 +1,7 @@ --- [E092] Pattern Match Error: tests/neg/15981.scala:4:45 -------------------------------------------------------------- -4 | override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // error +-- [E092] Pattern Match Unchecked Warning: tests/neg/15981.scala:4:45 -------------------------------------------------- +4 | override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn | ^^^ | the type test for PosInt cannot be checked at runtime because it's a local class | | longer explanation available when compiling with `-explain` +No warnings can be incurred under -Werror. diff --git a/tests/neg/15981.scala b/tests/neg/15981.scala index 5aba3555c010..fe8c2d3bd2cc 100644 --- a/tests/neg/15981.scala +++ b/tests/neg/15981.scala @@ -1,6 +1,7 @@ //> using options -Werror val _ = locally{ sealed abstract class PosInt(val value: Int) { - override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // error + override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn } } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/17284.check b/tests/neg/17284.check index fa248c598311..775f3e50b5f9 100644 --- a/tests/neg/17284.check +++ b/tests/neg/17284.check @@ -1,5 +1,5 @@ --- [E187] Potential Issue Error: tests/neg/17284.scala:4:6 ------------------------------------------------------------- -4 | 451.synchronized {} // error +-- [E187] Potential Issue Warning: tests/neg/17284.scala:4:6 ----------------------------------------------------------- +4 | 451.synchronized {} // warn | ^^^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |--------------------------------------------------------------------------------------------------------------------- @@ -8,8 +8,8 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. --------------------------------------------------------------------------------------------------------------------- --- [E187] Potential Issue Error: tests/neg/17284.scala:8:4 ------------------------------------------------------------- -8 | x.synchronized {} // error +-- [E187] Potential Issue Warning: tests/neg/17284.scala:8:4 ----------------------------------------------------------- +8 | x.synchronized {} // warn | ^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |--------------------------------------------------------------------------------------------------------------------- @@ -18,8 +18,8 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. --------------------------------------------------------------------------------------------------------------------- --- [E187] Potential Issue Error: tests/neg/17284.scala:11:7 ------------------------------------------------------------ -11 | true.synchronized {} // error +-- [E187] Potential Issue Warning: tests/neg/17284.scala:11:7 ---------------------------------------------------------- +11 | true.synchronized {} // warn | ^^^^^^^^^^^^^^^^^ | Suspicious synchronized call on boxed class |-------------------------------------------------------------------------------------------------------------------- @@ -28,3 +28,4 @@ | You called the synchronized method on a boxed primitive. This might not be what | you intended. -------------------------------------------------------------------------------------------------------------------- +No warnings can be incurred under -Werror. diff --git a/tests/neg/17284.scala b/tests/neg/17284.scala index 8f588233245a..5b99fd140193 100644 --- a/tests/neg/17284.scala +++ b/tests/neg/17284.scala @@ -1,14 +1,15 @@ //> using options -Werror -explain def test = - 451.synchronized {} // error + 451.synchronized {} // warn def test2 = val x: Integer = 451 - x.synchronized {} // error + x.synchronized {} // warn def test3 = - true.synchronized {} // error + true.synchronized {} // warn def test4 = true.hashCode() // success +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/18493.check b/tests/neg/18493.check index 79a2872e71e8..2e78702c12e9 100644 --- a/tests/neg/18493.check +++ b/tests/neg/18493.check @@ -1,8 +1,9 @@ --- [E030] Match case Unreachable Error: tests/neg/18493.scala:6:9 ------------------------------------------------------ -6 | case "abc" => // error +-- [E030] Match case Unreachable Warning: tests/neg/18493.scala:6:9 ---------------------------------------------------- +6 | case "abc" => // warn | ^^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/18493.scala:12:9 ----------------------------------------------------- -12 | case "abc" => // error +-- [E030] Match case Unreachable Warning: tests/neg/18493.scala:12:9 --------------------------------------------------- +12 | case "abc" => // warn | ^^^^^ | Unreachable case +No warnings can be incurred under -Werror. diff --git a/tests/neg/18493.scala b/tests/neg/18493.scala index 8dfb3bf923cc..006c275aa7fc 100644 --- a/tests/neg/18493.scala +++ b/tests/neg/18493.scala @@ -3,12 +3,13 @@ object PartialFunctionNoWarning { // nice warning "abc" match { case "abc" => - case "abc" => // error + case "abc" => // warn } // no warnings val pf: PartialFunction[String, Unit] = { case "abc" => - case "abc" => // error + case "abc" => // warn } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/IsInstanceOfClassTag2.scala b/tests/neg/IsInstanceOfClassTag2.scala index 9246c7fca84d..a2a7194d4e39 100644 --- a/tests/neg/IsInstanceOfClassTag2.scala +++ b/tests/neg/IsInstanceOfClassTag2.scala @@ -11,7 +11,7 @@ object IsInstanceOfClassTag { } def main(args: Array[String]): Unit = { - safeCast[List[String]](List[Int](1)) match { // error + safeCast[List[String]](List[Int](1)) match { // warn case None => case Some(xs) => } @@ -22,3 +22,5 @@ object IsInstanceOfClassTag { } } } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/adhoc-extension/B.scala b/tests/neg/adhoc-extension/B.scala index 2343a9bc0060..efa783f87178 100644 --- a/tests/neg/adhoc-extension/B.scala +++ b/tests/neg/adhoc-extension/B.scala @@ -1,10 +1,11 @@ //> using options -source future -feature -Xfatal-warnings package adhoc -class B extends A // error: adhoc-extension (under -strict -feature -Xfatal-warnings) -class C extends A // error +class B extends A // warn: adhoc-extension (under -strict -feature -Xfatal-warnings) +class C extends A // warn object O { - val a = new A {} // error - object E extends A // error -} \ No newline at end of file + val a = new A {} // warn + object E extends A // warn +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/avoid-warn-deprecation.scala b/tests/neg/avoid-warn-deprecation.scala index 45baf7addb86..f14ebd30a98f 100644 --- a/tests/neg/avoid-warn-deprecation.scala +++ b/tests/neg/avoid-warn-deprecation.scala @@ -8,4 +8,5 @@ object A { object B { A.foo } -// nopos-error there was 1 deprecation warning; re-run with -deprecation for details +// nopos-warn there was 1 deprecation warning; re-run with -deprecation for details +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/capt-wf.scala b/tests/neg/capt-wf.scala index 0e1e4be2ca67..fe18a6f5f16b 100644 --- a/tests/neg/capt-wf.scala +++ b/tests/neg/capt-wf.scala @@ -13,12 +13,12 @@ def test(c: Cap, other: String): Unit = val x3a: () -> String = s1 val s2 = () => if x1 == null then "" else "abc" val x4: C^{s2} = ??? // OK - val x5: C^{c, c} = ??? // error: redundant // error: redundant + val x5: C^{c, c} = ??? // warn: redundant // warn: redundant // val x6: C^{c}^{c} = ??? // would be syntax error - val x7: Cap^{c} = ??? // error: redundant + val x7: Cap^{c} = ??? // warn: redundant // val x8: C^{c}^{cap} = ??? // would be syntax error - val x9: C^{c, cap} = ??? // error: redundant - val x10: C^{cap, c} = ??? // error: redundant + val x9: C^{c, cap} = ??? // warn: redundant + val x10: C^{cap, c} = ??? // warn: redundant def even(n: Int): Boolean = if n == 0 then true else odd(n - 1) def odd(n: Int): Boolean = if n == 1 then true else even(n - 1) @@ -34,4 +34,5 @@ def test(c: Cap, other: String): Unit = if n == 0 then true else od(n - 1) val y3: String^{ev} = ??? // error cs is empty - () \ No newline at end of file + () +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/classtag-typetest/3_1-migration.scala b/tests/neg/classtag-typetest/3_1-migration.scala index 41e0537a6dc1..fb8f3beedc48 100644 --- a/tests/neg/classtag-typetest/3_1-migration.scala +++ b/tests/neg/classtag-typetest/3_1-migration.scala @@ -5,4 +5,5 @@ import scala.reflect.ClassTag def f3_1m[T: ClassTag](x: Any): Unit = x match - case _: T => // error + case _: T => // warn +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/classtag-typetest/3_1.scala b/tests/neg/classtag-typetest/3_1.scala index d9101ff2ae57..798489bb90fa 100644 --- a/tests/neg/classtag-typetest/3_1.scala +++ b/tests/neg/classtag-typetest/3_1.scala @@ -5,4 +5,5 @@ import scala.reflect.ClassTag def f3_1[T: ClassTag](x: Any): Unit = x match - case _: T => // error + case _: T => // warn +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/convertible.scala b/tests/neg/convertible.scala index e72de452f41d..9ddc75a982a7 100644 --- a/tests/neg/convertible.scala +++ b/tests/neg/convertible.scala @@ -11,9 +11,9 @@ object Test: def f(x: Text, y: => Text, zs: Text*) = println(s"${x.str} ${y.str} ${zs.map(_.str).mkString(" ")}") - f("abc", "def") // error // error - f("abc", "def", "xyz", "uvw") // error // error // error // error - f("abc", "def", "xyz", Text("uvw")) // error // error // error + f("abc", "def") // warn // warn + f("abc", "def", "xyz", "uvw") // warn // warn // warn // warn + f("abc", "def", "xyz", Text("uvw")) // warn // warn // warn def g(x: into Text) = println(x.str) @@ -27,5 +27,5 @@ object Test: def h(x: into Text) = val y = h1(x) - y("abc") // error, inference through type variable does not propagate - + y("abc") // warn, inference through type variable does not propagate +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/deprecated-override.scala b/tests/neg/deprecated-override.scala index b532416c7126..c167dd720666 100644 --- a/tests/neg/deprecated-override.scala +++ b/tests/neg/deprecated-override.scala @@ -7,10 +7,10 @@ class B extends A: @deprecatedOverriding def f = 1 class C extends B: - override def f = 2 // error + override def f = 2 // warn trait D extends A: override def f = 3 -object E extends B, D // error - +object E extends B, D // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/feature-shadowing.scala b/tests/neg/feature-shadowing.scala index 16286d5eea87..891d8735aa41 100644 --- a/tests/neg/feature-shadowing.scala +++ b/tests/neg/feature-shadowing.scala @@ -8,8 +8,9 @@ object a: object b: import language.implicitConversions as _ - val s: String = 2 // error + val s: String = 2 // warn object c: import language.implicitConversions val s: String = 3 // OK again +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/filtering-fors.scala b/tests/neg/filtering-fors.scala index 7d998a37f057..ef6d7790ce7e 100644 --- a/tests/neg/filtering-fors.scala +++ b/tests/neg/filtering-fors.scala @@ -8,18 +8,18 @@ object Test { for (x: Any <- xs) do () // OK for (x: String <- xs) do () // error - for ((x: String) <- xs) do () // error - for (y@ (x: String) <- xs) do () // error - for ((x, y) <- xs) do () // error + for ((x: String) <- xs) do () // warn + for (y@ (x: String) <- xs) do () // warn + for ((x, y) <- xs) do () // warn - for ((x: String) <- xs if x.isEmpty) do () // error - for ((x: String) <- xs; y = x) do () // error - for ((x: String) <- xs; (y, z) <- xs) do () // error // error - for (case (x: String) <- xs; (y, z) <- xs) do () // error - for ((x: String) <- xs; case (y, z) <- xs) do () // error + for ((x: String) <- xs if x.isEmpty) do () // warn + for ((x: String) <- xs; y = x) do () // warn + for ((x: String) <- xs; (y, z) <- xs) do () // warn // warn + for (case (x: String) <- xs; (y, z) <- xs) do () // warn + for ((x: String) <- xs; case (y, z) <- xs) do () // warn val pairs: List[AnyRef] = List((1, 2), "hello", (3, 4)) - for ((x, y) <- pairs) yield (y, x) // error + for ((x, y) <- pairs) yield (y, x) // warn for (case x: String <- xs) do () // OK for (case (x: String) <- xs) do () // OK @@ -31,4 +31,5 @@ object Test { for (case (x: String) <- xs; case (y, z) <- xs) do () // OK for (case (x, y) <- pairs) yield (y, x) // OK -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/gadt-contradictory-pattern.scala b/tests/neg/gadt-contradictory-pattern.scala index 6fbd06120a48..ed8b343c9545 100644 --- a/tests/neg/gadt-contradictory-pattern.scala +++ b/tests/neg/gadt-contradictory-pattern.scala @@ -6,9 +6,10 @@ object Test { case object Bar3 extends Foo[AnyRef] def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match { - case (Bar1, Bar1) => () // error // error + case (Bar1, Bar1) => () // warn // warn case (Bar2, Bar3) => () case (Bar3, _) => () } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i10247.scala b/tests/neg/i10247.scala index fc6268720a6d..e98b2dc6e9c2 100644 --- a/tests/neg/i10247.scala +++ b/tests/neg/i10247.scala @@ -1,6 +1,6 @@ //> using options -Xfatal-warnings -deprecation -def usered = Color.Red // error: value Red is deprecated +def usered = Color.Red // warn: value Red is deprecated object DeprecatedContainer { @deprecated("no foo", "0.1") val foo = 23 @@ -18,11 +18,12 @@ enum Color { @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 + 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 // error // check that only enum cases are avoided + def useFoo2 = DeprecatedContainer.foo // warn // check that only enum cases are avoided } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i10930.scala b/tests/neg/i10930.scala index 5f8a0ca1ba76..fe9009a52292 100644 --- a/tests/neg/i10930.scala +++ b/tests/neg/i10930.scala @@ -9,7 +9,8 @@ import language.future 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 + 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 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i10994.scala b/tests/neg/i10994.scala index f5f237f22dd6..ce553c77c5ae 100644 --- a/tests/neg/i10994.scala +++ b/tests/neg/i10994.scala @@ -1,4 +1,6 @@ //> using options -Xfatal-warnings def foo = true match - case (b: Boolean): Boolean => () // error + case (b: Boolean): Boolean => () // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i11022.check b/tests/neg/i11022.check index 55bdb0526264..65e3083d95e4 100644 --- a/tests/neg/i11022.check +++ b/tests/neg/i11022.check @@ -1,20 +1,21 @@ --- Error: tests/neg/i11022.scala:10:7 ---------------------------------------------------------------------------------- -10 |val a: CaseClass = CaseClass(42) // error: deprecated type // error: deprecated apply method +-- Deprecation Warning: tests/neg/i11022.scala:10:7 -------------------------------------------------------------------- +10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: 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 +-- Deprecation Warning: tests/neg/i11022.scala:10:19 ------------------------------------------------------------------- +10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: 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 +-- Deprecation Warning: tests/neg/i11022.scala:11:7 -------------------------------------------------------------------- +11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: 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 +-- Deprecation Warning: tests/neg/i11022.scala:11:23 ------------------------------------------------------------------- +11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: 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 +-- Deprecation Warning: tests/neg/i11022.scala:12:14 ------------------------------------------------------------------- +12 |val c: Unit = CaseClass(42).magic() // warn: deprecated apply method | ^^^^^^^^^ | class CaseClass is deprecated: no CaseClass +No warnings can be incurred under -Werror. diff --git a/tests/neg/i11022.scala b/tests/neg/i11022.scala index 14bc600666f9..475f65695251 100644 --- a/tests/neg/i11022.scala +++ b/tests/neg/i11022.scala @@ -7,7 +7,8 @@ case class CaseClass(rgb: Int): 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 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 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i11097.scala b/tests/neg/i11097.scala index 149fe89249c8..b1f0b0bfd300 100644 --- a/tests/neg/i11097.scala +++ b/tests/neg/i11097.scala @@ -4,12 +4,13 @@ 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 } // ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String val x = pmatch(new C { type T1 = String; type T2 = String }) -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i11225b.scala b/tests/neg/i11225b.scala index a9dd1d3d2227..b66cd3865f49 100644 --- a/tests/neg/i11225b.scala +++ b/tests/neg/i11225b.scala @@ -3,10 +3,12 @@ import compiletime.uninitialized class Memo[A](x: => A): - private var cached: A = _ // error + private var cached: A = _ // warn private var known: Boolean = false def force = if !known then known = true cached = x cached + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i11333.check b/tests/neg/i11333.check index ba5723488899..05f6de27062c 100644 --- a/tests/neg/i11333.check +++ b/tests/neg/i11333.check @@ -1,30 +1,31 @@ --- [E167] Lossy Conversion Error: tests/neg/i11333.scala:4:19 ---------------------------------------------------------- -4 | val f1: Float = 123456789 // error +-- [E167] Lossy Conversion Warning: tests/neg/i11333.scala:4:19 -------------------------------------------------------- +4 | val f1: Float = 123456789 // warn | ^^^^^^^^^ | 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 +-- [E167] Lossy Conversion Warning: tests/neg/i11333.scala:5:19 -------------------------------------------------------- +5 | val d1: Double = 1234567890123456789L // warn | ^^^^^^^^^^^^^^^^^^^^ | 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 +-- [E167] Lossy Conversion Warning: tests/neg/i11333.scala:6:19 -------------------------------------------------------- +6 | val f2: Float = 123456789L // warn | ^^^^^^^^^^ | 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 +-- [E167] Lossy Conversion Warning: tests/neg/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 Error: tests/neg/i11333.scala:13:21 --------------------------------------------------------- -13 | val d1_b: Double = l1 // error +-- [E167] Lossy Conversion Warning: tests/neg/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 Error: tests/neg/i11333.scala:14:21 --------------------------------------------------------- -14 | val f2_b: Float = l2 // error +-- [E167] Lossy Conversion Warning: tests/neg/i11333.scala:14:21 ------------------------------------------------------- +14 | val f2_b: Float = l2 // warn | ^^ | Widening conversion from Long to Float loses precision. | Write `.toFloat` instead. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i11333.scala b/tests/neg/i11333.scala index bbdcceaf7e1e..5149a99e7063 100644 --- a/tests/neg/i11333.scala +++ b/tests/neg/i11333.scala @@ -1,14 +1,15 @@ //> using options -Xfatal-warnings class C: - val f1: Float = 123456789 // error - val d1: Double = 1234567890123456789L // error - val f2: Float = 123456789L // error + 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 // error - val d1_b: Double = l1 // error - val f2_b: Float = l2 // error + val f1_b: Float = i1 // warn + val d1_b: Double = l1 // warn + val f2_b: Float = l2 // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i11344.scala b/tests/neg/i11344.scala index 0602fe14a995..04c1b6f7f2d3 100644 --- a/tests/neg/i11344.scala +++ b/tests/neg/i11344.scala @@ -3,6 +3,8 @@ 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 + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i11963a.scala b/tests/neg/i11963a.scala index 0eb2f557624f..5212a51826c4 100644 --- a/tests/neg/i11963a.scala +++ b/tests/neg/i11963a.scala @@ -1,3 +1,5 @@ //> using options -Xfatal-warnings -open trait Foo // error +open trait Foo // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i11963b.scala b/tests/neg/i11963b.scala index 76097b225896..e549488b79b7 100644 --- a/tests/neg/i11963b.scala +++ b/tests/neg/i11963b.scala @@ -1,3 +1,5 @@ //> using options -Xfatal-warnings -open abstract class Foo // error +open abstract class Foo // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i11963c.scala b/tests/neg/i11963c.scala index f58f68c72368..8e91632f0bc2 100644 --- a/tests/neg/i11963c.scala +++ b/tests/neg/i11963c.scala @@ -2,7 +2,9 @@ object Test { def foo: Any = { - open class Bar // error + open class Bar // warn new Bar } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i12188/Test.scala b/tests/neg/i12188/Test.scala index 66864438694e..9bbbf6431b13 100644 --- a/tests/neg/i12188/Test.scala +++ b/tests/neg/i12188/Test.scala @@ -7,5 +7,7 @@ case class PC2(b: Int) extends P def Test = MatchTest.test(PC2(10): P) def foo(x: P): Unit = - x match // error - case _: PC1 => \ No newline at end of file + x match // warn + case _: PC1 => + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i12253.check b/tests/neg/i12253.check index 75a698249dee..e0a5886ad676 100644 --- a/tests/neg/i12253.check +++ b/tests/neg/i12253.check @@ -1,13 +1,14 @@ --- [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/neg/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/neg/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 | | longer explanation available when compiling with `-explain` +No warnings can be incurred under -Werror. there was 1 deprecation warning; re-run with -deprecation for details diff --git a/tests/neg/i12253.scala b/tests/neg/i12253.scala index 540ff8ef6d5b..51677c10b5f0 100644 --- a/tests/neg/i12253.scala +++ b/tests/neg/i12253.scala @@ -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-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i12597.scala b/tests/neg/i12597.scala index b8859a0ae991..241e1b09e2a9 100644 --- a/tests/neg/i12597.scala +++ b/tests/neg/i12597.scala @@ -3,5 +3,7 @@ @main def Test = val a: IArray[Int] = IArray(2) val b: IArray[Any] = a - val c = b.toArray // error: deprecated + val c = b.toArray // warn: deprecated c(0) = "" + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i13011.scala b/tests/neg/i13011.scala index c0541aeb7f8e..fca3fcf7dded 100644 --- a/tests/neg/i13011.scala +++ b/tests/neg/i13011.scala @@ -1,23 +1,24 @@ //> 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 } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i13440.check b/tests/neg/i13440.check index c820ee67833d..b173835cc3bb 100644 --- a/tests/neg/i13440.check +++ b/tests/neg/i13440.check @@ -1,12 +1,13 @@ --- Error: tests/neg/i13440.scala:5:4 ----------------------------------------------------------------------------------- -5 |def given = 42 // error +-- Migration Warning: tests/neg/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 --- Error: tests/neg/i13440.scala:7:13 ---------------------------------------------------------------------------------- -7 |case class C(enum: List[Int] = Nil) { // error +-- Migration Warning: tests/neg/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 --- Error: tests/neg/i13440.scala:8:11 ---------------------------------------------------------------------------------- -8 | val s = s"$enum" // error +-- Migration Warning: tests/neg/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 +No warnings can be incurred under -Werror. diff --git a/tests/neg/i13440.scala b/tests/neg/i13440.scala index 443215c621ef..6b8bf99e08d3 100644 --- a/tests/neg/i13440.scala +++ b/tests/neg/i13440.scala @@ -2,8 +2,9 @@ import language.`3.0-migration` -def given = 42 // error +def given = 42 // warn -case class C(enum: List[Int] = Nil) { // error - val s = s"$enum" // error +case class C(enum: List[Int] = Nil) { // warn + val s = s"$enum" // warn } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i13542.scala b/tests/neg/i13542.scala index c0feb88b556d..404ddc0af2e5 100644 --- a/tests/neg/i13542.scala +++ b/tests/neg/i13542.scala @@ -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) @@ -45,8 +45,4 @@ val x6 = lazy val y = bar.toFoo if false then y else ??? val foo: Foo = Bar(1) - - - - - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i13946/BadPrinter.scala b/tests/neg/i13946/BadPrinter.scala index 46913d2c2805..39e8a921d498 100644 --- a/tests/neg/i13946/BadPrinter.scala +++ b/tests/neg/i13946/BadPrinter.scala @@ -2,5 +2,6 @@ // in BadPrinter.scala import language.future -class BadPrinter extends Printer: // error +class BadPrinter extends Printer: // warn override def print(s: String): Unit = println("Bad!!!") +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i14386.scala b/tests/neg/i14386.scala index be0b2497ed5f..d9647da49525 100644 --- a/tests/neg/i14386.scala +++ b/tests/neg/i14386.scala @@ -42,7 +42,8 @@ def braced() = s"""begin ${ val level = 10 - val msg = "hello, world" // error he lets me off with a warning - log(level, msg) // error + val msg = "hello, world" // warn he lets me off with a warning + log(level, msg) // warn } end""" +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i14705.scala b/tests/neg/i14705.scala index 9ffb4443416e..36646130a8a8 100644 --- a/tests/neg/i14705.scala +++ b/tests/neg/i14705.scala @@ -1,5 +1,7 @@ //> using options -Xfatal-warnings val n = Nil -val b = n.head.isInstanceOf[String] // error +val b = n.head.isInstanceOf[String] // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i14721.scala b/tests/neg/i14721.scala index 46786f04558b..46b9c4bb5b2a 100644 --- a/tests/neg/i14721.scala +++ b/tests/neg/i14721.scala @@ -6,4 +6,6 @@ class C: def test: Unit = try op catch case _: NullPointerException => - handler // error + handler // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i15474.scala b/tests/neg/i15474.scala index 8edf97a1e55a..ff4fd7b641ef 100644 --- a/tests/neg/i15474.scala +++ b/tests/neg/i15474.scala @@ -4,7 +4,7 @@ import scala.language.implicitConversions object Test1: given c: Conversion[ String, Int ] with - def apply(from: String): Int = from.toInt // error + def apply(from: String): Int = from.toInt // warn object Test2: given c: Conversion[ String, Int ] = _.toInt // loop not detected, could be used as a fallback to avoid the warning. @@ -13,6 +13,7 @@ object Prices { opaque type Price = BigDecimal object Price{ - given Ordering[Price] = summon[Ordering[BigDecimal]] // error + given Ordering[Price] = summon[Ordering[BigDecimal]] // warn } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15479.scala b/tests/neg/i15479.scala index d4f306a12368..0da30ab749e2 100644 --- a/tests/neg/i15479.scala +++ b/tests/neg/i15479.scala @@ -8,11 +8,13 @@ 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 +} + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503-scala2/scala2-t11681.scala b/tests/neg/i15503-scala2/scala2-t11681.scala index 2436668e0c9c..af11eb4512d6 100644 --- a/tests/neg/i15503-scala2/scala2-t11681.scala +++ b/tests/neg/i15503-scala2/scala2-t11681.scala @@ -10,7 +10,7 @@ trait InterFace { trait BadAPI extends InterFace { private def f(a: Int, - b: String, // error + b: String, // warn c: Double): Int = { println(c) a @@ -50,7 +50,7 @@ trait PoorClient extends BadAPI { override def f(a: Int, b: String, c: Double): Int = a + b.toInt + c.toInt } -class Unusing(u: Int) { // error +class Unusing(u: Int) { // warn def f = ??? } @@ -107,4 +107,6 @@ object Answers { def answer: Int = 42 } -val a$1 = 2 \ No newline at end of file +val a$1 = 2 + +// nopo-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503a.scala b/tests/neg/i15503a.scala index b5f17a1e2f52..b4655a37db33 100644 --- a/tests/neg/i15503a.scala +++ b/tests/neg/i15503a.scala @@ -2,12 +2,12 @@ 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 @@ -265,4 +265,5 @@ package foo.test.typeapply.hklamdba.i16680: import foo.IO // OK def f[F[_]]: String = "hello" - def go = f[IO] \ No newline at end of file + def go = f[IO] +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503b.scala b/tests/neg/i15503b.scala index 4dc10e12606d..f828812dfe5b 100644 --- a/tests/neg/i15503b.scala +++ b/tests/neg/i15503b.scala @@ -5,13 +5,13 @@ 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 } } @@ -142,3 +142,4 @@ package test.foo.twisted.i16682: isInt def f = myPackage("42") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503c.scala b/tests/neg/i15503c.scala index b93ce8825114..6475302e2f1d 100644 --- a/tests/neg/i15503c.scala +++ b/tests/neg/i15503c.scala @@ -5,25 +5,25 @@ class A: 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 +34,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 = @@ -55,3 +55,4 @@ package test.foo.i16682: } def f = myPackage.isInt("42") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503d.scala b/tests/neg/i15503d.scala index c43dc07c638e..82e94e60ba75 100644 --- a/tests/neg/i15503d.scala +++ b/tests/neg/i15503d.scala @@ -8,12 +8,12 @@ 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) => Z // warn 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) => a // warn + case Sum(a@S(b@S(_)), Z) => a // warn case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // OK case Sum(_,_) => Z // OK case _ => Z // OK @@ -28,3 +28,4 @@ val a = Sum(S(S(Z)),Z) match { // val c = for { // case Some(x) <- Option(Option(1)) // } println(s"hello world") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503e.scala b/tests/neg/i15503e.scala index f3214e7b24e6..84c5066dff57 100644 --- a/tests/neg/i15503e.scala +++ b/tests/neg/i15503e.scala @@ -5,10 +5,10 @@ object Foo { 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 @@ -68,4 +68,4 @@ package foo.test.i16865: object Ex2 extends Bar: override def fn(a: Int, b: Int): Int = b + 3 // OK - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503f.scala b/tests/neg/i15503f.scala index 08520d149b95..bea7cdf2a408 100644 --- a/tests/neg/i15503f.scala +++ b/tests/neg/i15503f.scala @@ -10,5 +10,7 @@ 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 } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503g.scala b/tests/neg/i15503g.scala index 4da98a8d43f2..2f74c48cdbcc 100644 --- a/tests/neg/i15503g.scala +++ b/tests/neg/i15503g.scala @@ -5,10 +5,10 @@ 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 @@ -21,3 +21,4 @@ package foo.test.i17101: def value: A = x def causesIssue: Unit = println("oh no") } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503h.scala b/tests/neg/i15503h.scala index cef1f6cf566f..a384df26b5f9 100644 --- a/tests/neg/i15503h.scala +++ b/tests/neg/i15503h.scala @@ -1,20 +1,21 @@ //> using options -Xfatal-warnings -Wunused:linted -import collection.mutable.Set // error +import collection.mutable.Set // warn class A { - private val a = 1 // error + private val a = 1 // warn val b = 2 // OK - private def c = 2 // error + private def c = 2 // warn def d(using x:Int): Int = b // ok def e(x: Int) = 1 // OK def f = - val x = 1 // error - def f = 2 // error + 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 +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503i.scala b/tests/neg/i15503i.scala index d415c95a701a..ff33e7cbb0c2 100644 --- a/tests/neg/i15503i.scala +++ b/tests/neg/i15503i.scala @@ -1,11 +1,11 @@ //> using options -Xfatal-warnings -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 } @@ -313,3 +313,4 @@ package foo.test.i17117: val test = t1.test } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15503j.scala b/tests/neg/i15503j.scala index 66140934abc1..2d40b5b49d24 100644 --- a/tests/neg/i15503j.scala +++ b/tests/neg/i15503j.scala @@ -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 @@ -56,4 +56,5 @@ package foo.unused.summon.inlines: new {} val b: B = summon[B] - val c: C = summon[C] \ No newline at end of file + val c: C = summon[C] +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15662.scala b/tests/neg/i15662.scala index 1b6070f26e00..366661c7bae4 100644 --- a/tests/neg/i15662.scala +++ b/tests/neg/i15662.scala @@ -4,7 +4,7 @@ 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 = @@ -14,3 +14,5 @@ def m2(composite: Composite[_]): Unit = @main def Test = m(Composite("This is String")) + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i15893.scala b/tests/neg/i15893.scala index d66da9ebec8b..79908e1e8615 100644 --- a/tests/neg/i15893.scala +++ b/tests/neg/i15893.scala @@ -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() @@ -61,3 +61,4 @@ inline def transparentInlineFoo(inline n: NatT): NatT = inline transparentInline 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 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i16639a.scala b/tests/neg/i16639a.scala index 66db96901e74..907fed7f0765 100644 --- a/tests/neg/i16639a.scala +++ b/tests/neg/i16639a.scala @@ -2,34 +2,34 @@ // 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 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 s1: Int = 0 // warn warn + private var s2: Int = 0 // warn warn, never set private var s3: Int = 0 // warn, never got /Dotty: no warn even if not usued 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 @@ -75,27 +75,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 +103,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 +126,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 +152,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 +190,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 +200,8 @@ 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 } } - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i16649-refutable.check b/tests/neg/i16649-refutable.check index a1325d7cfa91..b3e4e06624f2 100644 --- a/tests/neg/i16649-refutable.check +++ b/tests/neg/i16649-refutable.check @@ -1,8 +1,9 @@ --- Error: tests/neg/i16649-refutable.scala:6:6 ------------------------------------------------------------------------- -6 | val '{ ($y: Int) + ($z: Int) } = x // error +-- Warning: tests/neg/i16649-refutable.scala:6:6 ----------------------------------------------------------------------- +6 | val '{ ($y: Int) + ($z: Int) } = x // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | pattern binding uses refutable extractor `'{...}` | | If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression, | which may result in a MatchError at runtime. | This patch can be rewritten automatically under -rewrite -source 3.2-migration. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i16649-refutable.scala b/tests/neg/i16649-refutable.scala index 8caac5b2576a..62336caf87df 100644 --- a/tests/neg/i16649-refutable.scala +++ b/tests/neg/i16649-refutable.scala @@ -3,7 +3,9 @@ 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 + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i16728.check b/tests/neg/i16728.check index 93cc215696c2..64f4f5c9de76 100644 --- a/tests/neg/i16728.check +++ b/tests/neg/i16728.check @@ -1,6 +1,7 @@ --- [E092] Pattern Match Error: tests/neg/i16728.scala:18:11 ------------------------------------------------------------ -18 | case tx : C[Int]#X => // error +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 | | longer explanation available when compiling with `-explain` +No warnings can be incurred under -Werror. diff --git a/tests/neg/i16728.scala b/tests/neg/i16728.scala index b76bb03fa14a..8d00b4fbea3b 100644 --- a/tests/neg/i16728.scala +++ b/tests/neg/i16728.scala @@ -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,6 @@ object Test { } } -} \ No newline at end of file +} + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i16876/Test.scala b/tests/neg/i16876/Test.scala index 2dd6bfb34421..71a01128990e 100644 --- a/tests/neg/i16876/Test.scala +++ b/tests/neg/i16876/Test.scala @@ -4,8 +4,7 @@ object Foo { private def myMethod(a: Int, b: Int, c: Int) = adder // ok myMethod(1, 2, 3) - private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // error // error + private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // warn // warn myMethodFailing(1, 2, 3) } - - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i16930.scala b/tests/neg/i16930.scala index c7af60161424..6028b939813a 100644 --- a/tests/neg/i16930.scala +++ b/tests/neg/i16930.scala @@ -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,7 @@ 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 } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17266.check b/tests/neg/i17266.check index 1a84d1bf5e89..1cb89784ddcc 100644 --- a/tests/neg/i17266.check +++ b/tests/neg/i17266.check @@ -1,5 +1,5 @@ --- [E181] Potential Issue Error: tests/neg/i17266.scala:4:2 ------------------------------------------------------------ -4 | synchronized { // error +-- [E181] Potential Issue Warning: tests/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/i17266.scala:141:2 -------------------------------------------------------- +141 | hashCode() // warn | ^^^^^^^^ | Suspicious top-level unqualified call to hashCode |------------------------------------------------------------------------------------------------------------------- @@ -96,3 +96,4 @@ | resolved to calls on Predef or on imported methods. This might not be what | you intended. ------------------------------------------------------------------------------------------------------------------- +No warnings can be incurred under -Werror. diff --git a/tests/neg/i17266.scala b/tests/neg/i17266.scala index 439abafc44a1..23ed825e285c 100644 --- a/tests/neg/i17266.scala +++ b/tests/neg/i17266.scala @@ -1,7 +1,7 @@ //> using options -Werror -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,41 @@ 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) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17314b.scala b/tests/neg/i17314b.scala index 9e89fecde935..be7fda4682f7 100644 --- a/tests/neg/i17314b.scala +++ b/tests/neg/i17314b.scala @@ -6,9 +6,11 @@ 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]] + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i17612a.check b/tests/neg/i17612a.check index 04a5b07b6e33..48e5b9c17be9 100644 --- a/tests/neg/i17612a.check +++ b/tests/neg/i17612a.check @@ -1,32 +1,33 @@ --- 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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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 +No warnings can be incurred under -Werror. diff --git a/tests/neg/i17612a.scala b/tests/neg/i17612a.scala index 1145cd76edc0..5aba92b095f3 100644 --- a/tests/neg/i17612a.scala +++ b/tests/neg/i17612a.scala @@ -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) @@ -39,4 +39,5 @@ object i17612a: derived.increment() println(derived.toString) // still x: '1', probably unexpected, for y it never prints the super value, less surprising println(derived.shadowed2) - println(derived.shadowed3) \ No newline at end of file + println(derived.shadowed3) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17612b.check b/tests/neg/i17612b.check index 75e8b7312833..ae5b071d6187 100644 --- a/tests/neg/i17612b.check +++ b/tests/neg/i17612b.check @@ -1,32 +1,33 @@ --- Error: tests/neg/i17612b/i17612b.scala:21:15 ------------------------------------------------------------------------ -21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/neg/i17612b/i17612b.scala:21:15 ---------------------------------------------------------------------- +21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), 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 trait Base --- Error: tests/neg/i17612b/i17612b.scala:21:33 ------------------------------------------------------------------------ -21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), Base(x, y + 1, z2): // error // error / for x, y translated to private[this] x field & shadowing var Base.x, Base.y +-- Warning: tests/neg/i17612b/i17612b.scala:21:33 ---------------------------------------------------------------------- +21 | class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), 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 trait Base --- Error: tests/neg/i17612b/i17612b.scala:23:2 ------------------------------------------------------------------------- -23 | private val shadowed2 = 2 + 2 // error (In Scala 2 we cannot do that got the warning) +-- Warning: tests/neg/i17612b/i17612b.scala:23:2 ----------------------------------------------------------------------- +23 | 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 trait Base --- Error: tests/neg/i17612b/i17612b.scala:24:2 ------------------------------------------------------------------------- -24 | private[this] val shadowed3 = 3 + 3 // error +-- Warning: tests/neg/i17612b/i17612b.scala:24:2 ----------------------------------------------------------------------- +24 | private[this] val shadowed3 = 3 + 3 // warn | ^ | value shadowed3 in class Derived shadows field shadowed3 inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:26:2 ------------------------------------------------------------------------- -26 | private val shadowed5 = 5 + 5 // error +-- Warning: tests/neg/i17612b/i17612b.scala:26:2 ----------------------------------------------------------------------- +26 | private val shadowed5 = 5 + 5 // warn | ^ | value shadowed5 in class Derived shadows field shadowed5 inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:41:20 ------------------------------------------------------------------------ -41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error +-- Warning: tests/neg/i17612b/i17612b.scala:41:20 ---------------------------------------------------------------------- +41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn | ^ | value x in class UnderDerived shadows field x inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:41:28 ------------------------------------------------------------------------ -41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error +-- Warning: tests/neg/i17612b/i17612b.scala:41:28 ---------------------------------------------------------------------- +41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn | ^ | value y in class UnderDerived shadows field y inherited from trait Base --- Error: tests/neg/i17612b/i17612b.scala:41:36 ------------------------------------------------------------------------ -41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error +-- Warning: tests/neg/i17612b/i17612b.scala:41:36 ---------------------------------------------------------------------- +41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn | ^ | value z in class UnderDerived shadows field z inherited from trait Base +No warnings can be incurred under -Werror. diff --git a/tests/neg/i17612b/i17612b.scala b/tests/neg/i17612b/i17612b.scala index b59352f562d0..9b0fa7cf6259 100644 --- a/tests/neg/i17612b/i17612b.scala +++ b/tests/neg/i17612b/i17612b.scala @@ -18,12 +18,12 @@ object i17612b: trait BaseB trait BaseC(var x2: Int) - class Derived(x : Int, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), 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, x3: Int, y: Int, z2: Int) extends BaseB, BaseC(x3), 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 val shadowed5 = 5 + 5 // error + private val shadowed5 = 5 + 5 // warn private val notShadowed2 = -4 val lambda: Int => Int => Int = @@ -38,7 +38,8 @@ object i17612b: override def toString = s"x : ${x.toString}, y : ${y.toString}" - class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // error // error // error + class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn def main(args: Array[String]) = val derived = new Derived(1, 1, 1, 1) +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17613a.check b/tests/neg/i17613a.check index 4721b786c82d..eccafae81427 100644 --- a/tests/neg/i17613a.check +++ b/tests/neg/i17613a.check @@ -1,28 +1,29 @@ --- Error: tests/neg/i17613a.scala:8:13 --------------------------------------------------------------------------------- -8 | def foobar[D](in: D) = in.toString // error method parameter shadows some other type +-- Warning: tests/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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 +No warnings can be incurred under -Werror. diff --git a/tests/neg/i17613a.scala b/tests/neg/i17613a.scala index d0e413098cec..e161c5908297 100644 --- a/tests/neg/i17613a.scala +++ b/tests/neg/i17613a.scala @@ -5,19 +5,20 @@ object i17613a: 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 + 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): // error class parameter shadows some other type - def bar[T](w: T) = w.toString // error a type parameter shadows another type parameter + 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[_]]] // error - type E[M[List[_]]] = Int // error - def foo[N[M[List[_]]]] = ??? // error + 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") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i17613b/i17613b.scala b/tests/neg/i17613b/i17613b.scala index b0c4f11b949c..a5c0eaacc20f 100644 --- a/tests/neg/i17613b/i17613b.scala +++ b/tests/neg/i17613b/i17613b.scala @@ -6,39 +6,40 @@ object i17613b: type T = Int trait D - def foobar[ImTrait](in: D) = in.toString // error - type MySeq[ImTrait] = Seq[D] // error + def foobar[ImTrait](in: D) = in.toString // warn + type MySeq[ImTrait] = Seq[D] // warn - def foobar2[ImClass](in: D) = in.toString // error - type MySeq2[ImClass] = Seq[D] // error + def foobar2[ImClass](in: D) = in.toString // warn + type MySeq2[ImClass] = Seq[D] // warn - given [A]: Ordering[Int]() - type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] // error - type PolyFun[A] = [ImTrait] => ImTrait => B // error + given [A]: Ordering[Int]() // error + type TypeLambda[A] = [ImTrait] =>> Map[ImTrait, B] + type PolyFun[A] = [ImTrait] => ImTrait => B // warn type MatchType[A] = A match { case String => Int case ImTrait => Boolean } - class Foo[T](t: T): // error class parameter shadows some other type + class Foo[T](t: T): // warn class parameter shadows some other type import scala.collection.immutable.{List => List1} def bar[List](w: T) = w.toString // no warning due to the explicit import renaming - def intType[List1](x: T) = x.toString() // error + def intType[List1](x: T) = x.toString() // warn type Y[List] = Int // no warning given [A]: Ordering[A]() - given [Int]: Ordering[Int]() // error + given [Int]: Ordering[Int]() // warn - class C[M[List[_]]] // error List not renamed here - type E[M[Int[_]]] = Int // error + class C[M[List[_]]] // warn List not renamed here + type E[M[Int[_]]] = Int // warn - def foo[N[M[List[_]]]] = // error + def foo[N[M[List[_]]]] = // warn import importTry.{ImClass => ImClassR} def inner[ImClass] = // no warning - type Z[ImClassR] = Int // error - class InnerCl[ImClassR] // error + type Z[ImClassR] = Int // warn + class InnerCl[ImClassR] // warn 5 - def main(args: Array[String]) = println("Test for type parameter shadow") \ No newline at end of file + def main(args: Array[String]) = println("Test for type parameter shadow") +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i18722.check b/tests/neg/i18722.check index 539e23787752..d6ebf3d6b474 100644 --- a/tests/neg/i18722.check +++ b/tests/neg/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/neg/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/neg/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/neg/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/neg/i18722.scala:7:15 --------------------------------------------------------- +7 |def f4: Unit = i // warn | ^ | Discarded non-Unit value of type Int. You may want to use `()`. |--------------------------------------------------------------------------------------------------------------------- @@ -42,3 +42,4 @@ | Here the `i` expression is a pure statement that can be discarded. | Therefore the expression is effectively equivalent to `()`. --------------------------------------------------------------------------------------------------------------------- +No warnings can be incurred under -Werror. diff --git a/tests/neg/i18722.scala b/tests/neg/i18722.scala index c68390b76201..1c32aae3ae26 100644 --- a/tests/neg/i18722.scala +++ b/tests/neg/i18722.scala @@ -1,9 +1,10 @@ //> using options -Werror -explain -def f1: Unit = null // error -def f2: Unit = 1 // error -def f3: Unit = "a" // error +def f1: Unit = null // warn +def f2: Unit = 1 // warn +def f3: Unit = "a" // warn val i: Int = 1 -def f4: Unit = i // error +def f4: Unit = i // warn val u: Unit = () def f5: Unit = u +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i2333.scala b/tests/neg/i2333.scala index 67cddbc73f48..5cbf8fcd40cb 100644 --- a/tests/neg/i2333.scala +++ b/tests/neg/i2333.scala @@ -6,6 +6,7 @@ } object Test { - new Foo // error: deprecated - new Foo(1) // error: deprecated -} \ No newline at end of file + new Foo // warn: deprecated + new Foo(1) // warn: deprecated +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i2673.scala b/tests/neg/i2673.scala index 62c787fa00fb..77abe1a06d16 100644 --- a/tests/neg/i2673.scala +++ b/tests/neg/i2673.scala @@ -2,5 +2,7 @@ package Foos -class Foo // error +class Foo // warn class foo + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i2673b.scala b/tests/neg/i2673b.scala index 26e09ec3297e..6481ab469943 100644 --- a/tests/neg/i2673b.scala +++ b/tests/neg/i2673b.scala @@ -2,5 +2,7 @@ package Foos -class Bar // error +class Bar // warn object bar + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i2673c.scala b/tests/neg/i2673c.scala index 575d8c25d9e0..46e8ff828c18 100644 --- a/tests/neg/i2673c.scala +++ b/tests/neg/i2673c.scala @@ -3,6 +3,8 @@ package Foos object Outer { - case class X() // error + case class X() // warn object x } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i3561.scala b/tests/neg/i3561.scala index 862e65f3c2f7..0a19e01e8ab6 100644 --- a/tests/neg/i3561.scala +++ b/tests/neg/i3561.scala @@ -2,17 +2,18 @@ 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 } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i4008.check b/tests/neg/i4008.check index c1f27866d1c1..accc8b0d29b2 100644 --- a/tests/neg/i4008.check +++ b/tests/neg/i4008.check @@ -1,40 +1,41 @@ --- [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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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`. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i4008.scala b/tests/neg/i4008.scala index 5b851c987e37..fb24c25fc4ff 100644 --- a/tests/neg/i4008.scala +++ b/tests/neg/i4008.scala @@ -4,23 +4,23 @@ // 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,9 @@ 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 +def someMethod2[A](using @annotation.implicitNotFound("No C[${A}] found") sc: C[A]) = "" +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i4364.scala b/tests/neg/i4364.scala index 85dca443f6d4..225fd1dd0384 100644 --- a/tests/neg/i4364.scala +++ b/tests/neg/i4364.scala @@ -6,6 +6,8 @@ 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 } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i4812.check b/tests/neg/i4812.check index f4aee0e35dde..fccaa62f0c80 100644 --- a/tests/neg/i4812.check +++ b/tests/neg/i4812.check @@ -1,42 +1,43 @@ --- [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 +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 Error: tests/neg/i4812.scala:18:11 ------------------------------------------------------------- -18 | case prev: A => // error: the type test for A cannot be checked at runtime +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 Error: tests/neg/i4812.scala:28:11 ------------------------------------------------------------- -28 | case prev: A => // error: the type test for A cannot be checked at runtime +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 Error: tests/neg/i4812.scala:38:11 ------------------------------------------------------------- -38 | case prev: A => // error: the type test for A cannot be checked at runtime +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 Error: tests/neg/i4812.scala:50:13 ------------------------------------------------------------- -50 | case prev: A => // error: the type test for A cannot be checked at runtime +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 Error: tests/neg/i4812.scala:60:11 ------------------------------------------------------------- -60 | case prev: A => // error: the type test for A cannot be checked at runtime +-- [E092] Pattern Match Unchecked Warning: tests/neg/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 Error: tests/neg/i4812.scala:96:11 ------------------------------------------------------------- -96 | case x: B => // error: the type test for B cannot be checked at runtime +-- [E092] Pattern Match Unchecked Warning: tests/neg/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` +No warnings can be incurred under -Werror. diff --git a/tests/neg/i4812.scala b/tests/neg/i4812.scala index 8d518107825c..a2fcd87a134c 100644 --- a/tests/neg/i4812.scala +++ b/tests/neg/i4812.scala @@ -5,7 +5,7 @@ object Test: 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 = _ } 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) @@ -117,3 +117,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 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i4936b.scala b/tests/neg/i4936b.scala index 58c240e92309..80d9de8aeb7d 100644 --- a/tests/neg/i4936b.scala +++ b/tests/neg/i4936b.scala @@ -1,3 +1,5 @@ //> using options -Xfatal-warnings -final object Foo // error +final object Foo // warn + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i4986b.check b/tests/neg/i4986b.check index db30dcba8003..60a5163ba756 100644 --- a/tests/neg/i4986b.check +++ b/tests/neg/i4986b.check @@ -1,40 +1,41 @@ --- [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/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}.") // 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/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}.") // 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/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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`. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i4986b.scala b/tests/neg/i4986b.scala index c726e40fd4d8..9df1eea64e28 100644 --- a/tests/neg/i4986b.scala +++ b/tests/neg/i4986b.scala @@ -2,21 +2,22 @@ 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 } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i4986d.scala b/tests/neg/i4986d.scala index 909221bea5f0..73c92822a291 100644 --- a/tests/neg/i4986d.scala +++ b/tests/neg/i4986d.scala @@ -3,10 +3,10 @@ trait Foo[A] type Fooable[A] = { - def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // error + def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // warn type InnerFooable = { - def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // error + def foo(implicit @annotation.implicitNotFound("There's no Foo[${A}]") ev: Foo[A]): Any // warn } } @@ -22,3 +22,4 @@ trait Bar[A] type Barable[A] = { def bar(implicit ev: Bar[A]): Any // ok } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i5013.scala b/tests/neg/i5013.scala index adf09e2cf3be..1950770e8204 100644 --- a/tests/neg/i5013.scala +++ b/tests/neg/i5013.scala @@ -2,10 +2,11 @@ class Foo { - def foo1: Unit = 2 // error: A pure expression does nothing in statement position + def foo1: Unit = 2 // warn: 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 + 3 // warn: A pure expression does nothing in statement position + 4 // warn: A pure expression does nothing in statement position } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i5013b.scala b/tests/neg/i5013b.scala index 7ccaf47c12f3..6321538ffef2 100644 --- a/tests/neg/i5013b.scala +++ b/tests/neg/i5013b.scala @@ -11,8 +11,10 @@ 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 } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i5077.scala b/tests/neg/i5077.scala index 64de24bfd669..7ea64acf5fb1 100644 --- a/tests/neg/i5077.scala +++ b/tests/neg/i5077.scala @@ -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") } @@ -30,4 +30,5 @@ def Test = { case C(IsString, s) => println(s"A String with length ${s.length}") case _ => println("No match") } -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i6190b.check b/tests/neg/i6190b.check index 5d4dbd7c24cb..56f23d92f671 100644 --- a/tests/neg/i6190b.check +++ b/tests/neg/i6190b.check @@ -1,4 +1,5 @@ --- Error: tests/neg/i6190b.scala:5:29 ---------------------------------------------------------------------------------- -5 |def foo = List("1", "2").map(Rule) // error +-- Warning: tests/neg/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. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i6190b.scala b/tests/neg/i6190b.scala index 42270c1a984c..2f81d0a5a759 100644 --- a/tests/neg/i6190b.scala +++ b/tests/neg/i6190b.scala @@ -2,4 +2,6 @@ case class Rule(name: String) -def foo = List("1", "2").map(Rule) // error +def foo = List("1", "2").map(Rule) // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i7314.scala b/tests/neg/i7314.scala index b865f2ad881b..541e18c25761 100644 --- a/tests/neg/i7314.scala +++ b/tests/neg/i7314.scala @@ -5,7 +5,9 @@ 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 + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i7821.scala b/tests/neg/i7821.scala index 5275c06e487f..6604af7604c1 100644 --- a/tests/neg/i7821.scala +++ b/tests/neg/i7821.scala @@ -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 } } @@ -24,3 +24,4 @@ object Main extends App { println(XObject.anX + XObject.anX) // prints 10 println(MyXObject.anX + MyXObject.anX) // infinite loop } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i7821b.scala b/tests/neg/i7821b.scala index f82a38d259e1..93598b968adf 100644 --- a/tests/neg/i7821b.scala +++ b/tests/neg/i7821b.scala @@ -2,12 +2,13 @@ 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 + { 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 } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8427.scala b/tests/neg/i8427.scala index 3db449bed41c..7c22184aeb03 100644 --- a/tests/neg/i8427.scala +++ b/tests/neg/i8427.scala @@ -1,9 +1,10 @@ //> using options -Xfatal-warnings -@SerialVersionUID(1L) // error +@SerialVersionUID(1L) // warn trait T object Test { var t: T = compiletime.uninitialized def main(args: Array[String]) = println("hi") } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i8681.scala b/tests/neg/i8681.scala index 4d91509eb0d3..f7e7066fd2e0 100644 --- a/tests/neg/i8681.scala +++ b/tests/neg/i8681.scala @@ -13,4 +13,5 @@ val b = (A(1): A | B) match { case A(_) => "OK" case B(_) => "OK" case C(_) => "NOT OK" // error -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8711.check b/tests/neg/i8711.check index 5dbeeb22460c..10764e936b5a 100644 --- a/tests/neg/i8711.check +++ b/tests/neg/i8711.check @@ -1,12 +1,21 @@ --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:9:9 ------------------------------------------------------ +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:9:9 ---------------------------------------------------- 9 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B | ^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:14:9 ----------------------------------------------------- +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:14:9 --------------------------------------------------- 14 | case x: C => x // error | ^^^^ | Unreachable case --- [E030] Match case Unreachable Error: tests/neg/i8711.scala:19:9 ----------------------------------------------------- -19 | case x: (B | C) => x // error +-- [E030] Match case Unreachable Warning: tests/neg/i8711.scala:19:9 --------------------------------------------------- +19 | case x: (B | C) => x // warn | ^^^^^^^^^^ | Unreachable case +-- Error: tests/neg/i8711.scala:9:9 ------------------------------------------------------------------------------------ +9 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B + | ^ + | this case is unreachable since type A and class B are unrelated +-- Error: tests/neg/i8711.scala:14:9 ----------------------------------------------------------------------------------- +14 | case x: C => x // error + | ^ + | this case is unreachable since type A | B and class C are unrelated +No warnings can be incurred under -Werror. diff --git a/tests/neg/i8711.scala b/tests/neg/i8711.scala index 2647e20fe03b..0ae32393a327 100644 --- a/tests/neg/i8711.scala +++ b/tests/neg/i8711.scala @@ -16,7 +16,9 @@ object Test { } def baz(x: A) = x match { - case x: (B | C) => x // error + case x: (B | C) => x // warn case _ => } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i8781b.scala b/tests/neg/i8781b.scala index 7c9b074e1be7..01cd7ef69096 100644 --- a/tests/neg/i8781b.scala +++ b/tests/neg/i8781b.scala @@ -4,4 +4,6 @@ object Test: println((3: Boolean | Int).isInstanceOf[Boolean]) - println(3.isInstanceOf[Boolean]) // error + println(3.isInstanceOf[Boolean]) // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i8922b.scala b/tests/neg/i8922b.scala index 9e615a8d5b58..c199f5be5bd4 100644 --- a/tests/neg/i8922b.scala +++ b/tests/neg/i8922b.scala @@ -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,6 @@ object Interpreter { } } -} \ No newline at end of file +} + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9166.scala b/tests/neg/i9166.scala index b9644bf56f71..bfb30937fb21 100644 --- a/tests/neg/i9166.scala +++ b/tests/neg/i9166.scala @@ -1,7 +1,9 @@ //> using options -Xfatal-warnings -Wimplausible-patterns object UnitTest extends App { def foo(m: Unit) = m match { - case runtime.BoxedUnit.UNIT => println("ok") // error + case runtime.BoxedUnit.UNIT => println("ok") // warn } foo(()) } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i9241.scala b/tests/neg/i9241.scala index e7c959fc9ee2..a169ce709b5f 100644 --- a/tests/neg/i9241.scala +++ b/tests/neg/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,28 @@ 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 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9266.check b/tests/neg/i9266.check index bd80a017da02..d3c0ab354c16 100644 --- a/tests/neg/i9266.check +++ b/tests/neg/i9266.check @@ -1,5 +1,6 @@ --- Error: tests/neg/i9266.scala:5:22 ----------------------------------------------------------------------------------- -5 |def test = { implicit x: Int => x + x } // error +-- Migration Warning: tests/neg/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. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i9266.scala b/tests/neg/i9266.scala index e6f8db7417c7..168f1fa1b551 100644 --- a/tests/neg/i9266.scala +++ b/tests/neg/i9266.scala @@ -2,4 +2,6 @@ import language.`future-migration` -def test = { implicit x: Int => x + x } // error +def test = { implicit x: Int => x + x } // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i9408a.check b/tests/neg/i9408a.check index d9deb9cddaf7..699128cdc5ce 100644 --- a/tests/neg/i9408a.check +++ b/tests/neg/i9408a.check @@ -1,24 +1,25 @@ --- Error: tests/neg/i9408a.scala:18:20 --------------------------------------------------------------------------------- -18 | val length: Int = "qwerty" // error +-- Migration Warning: tests/neg/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/neg/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/neg/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/neg/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/neg/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/neg/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. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i9408a.scala b/tests/neg/i9408a.scala index 594417ec3215..d3544ec20be5 100644 --- a/tests/neg/i9408a.scala +++ b/tests/neg/i9408a.scala @@ -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 { @@ -86,3 +86,4 @@ object Test15 { def foo(implicit ev: Seq[Int]): Unit = ??? foo } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9408b.check b/tests/neg/i9408b.check index 5f8a854a9282..4d86f5a0ef0b 100644 --- a/tests/neg/i9408b.check +++ b/tests/neg/i9408b.check @@ -1,5 +1,6 @@ --- Error: tests/neg/i9408b/Test_2.scala:8:20 --------------------------------------------------------------------------- -8 | val length: Int = "abc" // error +-- Migration Warning: tests/neg/i9408b/Test_2.scala:8:20 --------------------------------------------------------------- +8 | val length: Int = "abc" // warn | ^^^^^ |The conversion (test.conversions.Conv.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. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i9408b/Test_2.scala b/tests/neg/i9408b/Test_2.scala index 6b3cbbafcb0e..11cad10f1e9f 100644 --- a/tests/neg/i9408b/Test_2.scala +++ b/tests/neg/i9408b/Test_2.scala @@ -5,5 +5,7 @@ import scala.language.implicitConversions object Test { import test.conversions.Conv.* - val length: Int = "abc" // error + val length: Int = "abc" // warn } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9740.check b/tests/neg/i9740.check index 359603a2863a..1d8280ca1963 100644 --- a/tests/neg/i9740.check +++ b/tests/neg/i9740.check @@ -1,12 +1,13 @@ --- [E186] Type Error: tests/neg/i9740.scala:10:9 ----------------------------------------------------------------------- -10 | case RecoveryCompleted => println("Recovery completed") // error +-- [E186] Type Warning: tests/neg/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/neg/i9740.scala:15:9 --------------------------------------------------------------------- +15 | case RecoveryCompleted => // warn | ^^^^^^^^^^^^^^^^^ | Implausible pattern: | RecoveryCompleted could match selector of type TypedRecoveryCompleted | only if there is an `equals` method identifying elements of the two types. +No warnings can be incurred under -Werror. diff --git a/tests/neg/i9740.scala b/tests/neg/i9740.scala index 6222298df48b..8e5f56eaab0d 100644 --- a/tests/neg/i9740.scala +++ b/tests/neg/i9740.scala @@ -7,11 +7,12 @@ 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 => } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9740b.scala b/tests/neg/i9740b.scala index dcd9a1d6a474..3f3f9a85222c 100644 --- a/tests/neg/i9740b.scala +++ b/tests/neg/i9740b.scala @@ -10,11 +10,12 @@ 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 => } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9740c.scala b/tests/neg/i9740c.scala index c6a3a1380f1d..b250ac907454 100644 --- a/tests/neg/i9740c.scala +++ b/tests/neg/i9740c.scala @@ -12,6 +12,8 @@ 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) => } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i9740d.scala b/tests/neg/i9740d.scala index 6f3cc3be02e2..ee0df4ea7cf7 100644 --- a/tests/neg/i9740d.scala +++ b/tests/neg/i9740d.scala @@ -9,5 +9,6 @@ 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 UnitExp => // warn } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/i9751.scala b/tests/neg/i9751.scala index 618d237e0cd4..1b3fa1a01656 100644 --- a/tests/neg/i9751.scala +++ b/tests/neg/i9751.scala @@ -1,11 +1,12 @@ //> using options -Xfatal-warnings def f(): Unit = { - () // error + () // warn () } inline def g(): Unit = { - () // error + () // warn () } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9776.scala b/tests/neg/i9776.scala index b05488810416..d0f512454a31 100644 --- a/tests/neg/i9776.scala +++ b/tests/neg/i9776.scala @@ -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 @@ -59,3 +59,4 @@ object TaggedFruit { case Apple.tag => true } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/i9880.scala b/tests/neg/i9880.scala index f99fae25e5dc..963711277faf 100644 --- a/tests/neg/i9880.scala +++ b/tests/neg/i9880.scala @@ -3,7 +3,7 @@ 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 // @@ -30,3 +30,4 @@ 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 +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/impl-conv/A.scala b/tests/neg/impl-conv/A.scala index 31eccf4fa4f7..9c47e67ca789 100644 --- a/tests/neg/impl-conv/A.scala +++ b/tests/neg/impl-conv/A.scala @@ -2,7 +2,7 @@ package implConv object A { - implicit def s2i(x: String): Int = Integer.parseInt(x) // error: feature + implicit def s2i(x: String): Int = Integer.parseInt(x) // warn: feature given i2s: Conversion[Int, String] = _.toString // ok implicit class Foo(x: String) { diff --git a/tests/neg/impl-conv/B.scala b/tests/neg/impl-conv/B.scala index 618868b8bbc0..b475c460f318 100644 --- a/tests/neg/impl-conv/B.scala +++ b/tests/neg/impl-conv/B.scala @@ -8,5 +8,6 @@ object B { "".foo val x: Int = "" // ok - val y: String = 1 // error: feature + val y: String = 1 // warn: feature } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/implicit-conversions-old.scala b/tests/neg/implicit-conversions-old.scala index 0a7b75766bbf..c1267ae79064 100644 --- a/tests/neg/implicit-conversions-old.scala +++ b/tests/neg/implicit-conversions-old.scala @@ -5,15 +5,15 @@ class B object A { - implicit def a2b(x: A): B = ??? // error under -Xfatal-warnings -feature + implicit def a2b(x: A): B = ??? // warn under -Xfatal-warnings -feature - implicit def b2a(x: B): A = ??? // error 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 = ??? // error under -Xfatal-warnings -feature + implicit def a2c(x: A): C = ??? // warn under -Xfatal-warnings -feature } object Test { @@ -22,4 +22,5 @@ object Test { 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 +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/implicit-conversions.scala b/tests/neg/implicit-conversions.scala index ead8c5ac7646..154fc0689d98 100644 --- a/tests/neg/implicit-conversions.scala +++ b/tests/neg/implicit-conversions.scala @@ -25,7 +25,8 @@ 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 -} \ No newline at end of file + 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 +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/indentLeft.scala b/tests/neg/indentLeft.scala index c4a260583de2..7e1cf8041bc7 100644 --- a/tests/neg/indentLeft.scala +++ b/tests/neg/indentLeft.scala @@ -1,10 +1,11 @@ //> using options -Xfatal-warnings +// nopos-error: No warnings can be incurred under -Werror. object Test { if (true) { println("hi") - println("!") // error: too far to the left + println("!") // warn: too far to the left } // error: too far to the left \ No newline at end of file diff --git a/tests/neg/indentRight.scala b/tests/neg/indentRight.scala index 8eb9deb23389..6c43651d67e6 100644 --- a/tests/neg/indentRight.scala +++ b/tests/neg/indentRight.scala @@ -1,19 +1,19 @@ //> using options -no-indent -Xfatal-warnings trait A - case class B() extends A // error: Line is indented too far to the right - case object C extends A // error: Line is indented too far to the right + case class B() extends A // warn: Line is indented too far to the right + case object C extends A // warn: Line is indented too far to the right object Test { if (true) println("ho") - println("hu") // error: Line is indented too far to the right + println("hu") // warn: Line is indented too far to the right if (true) { println("ho") } - println("hu") // error: Line is indented too far to the right + println("hu") // warn: Line is indented too far to the right while (true) () @@ -24,8 +24,8 @@ object Test { } trait A - case class B() extends A // error: Line is indented too far to the right - case object C extends A // error: Line is indented too far to the right + case class B() extends A // warn: Line is indented too far to the right + case object C extends A // warn: Line is indented too far to the right if (true) // OK println("hi") @@ -33,4 +33,4 @@ object Test { println("!") // error: expected a toplevel definition } - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/infix.scala b/tests/neg/infix.scala index aefdd5c40d47..2be1e3091eed 100644 --- a/tests/neg/infix.scala +++ b/tests/neg/infix.scala @@ -23,8 +23,8 @@ def test() = { c.op(2) c.iop(2) - c mop 2 // error: should not be used as infix operator - c meth 2 // error: should not be used as infix operator + c mop 2 // warn: should not be used as infix operator + c meth 2 // warn: should not be used as infix operator c `meth` 2 // OK, sincd `meth` is backquoted c + 3 // OK, since `+` is symbolic 1 to 2 // OK, since `to` is defined by Scala-2 @@ -42,9 +42,9 @@ def test() = { class Map[X, Y] - val x1: Int Map String = ??? // error + val x1: Int Map String = ??? // warn val x2: Int Or String = ??? // OK since Or is declared `infix` - val x3: Int AndC String = ??? // error + val x3: Int AndC String = ??? // warn val x4: Int `AndC` String = ??? // OK val x5: Int And String = ??? // OK val x6: Int && String = ??? @@ -58,7 +58,7 @@ def test() = { val p = Pair(1, 2) val Pair(_, _) = p - val _ Pair _ = p // error + val _ Pair _ = p // warn val _ `Pair` _ = p // OK val (_ PP _) = p: @unchecked // OK @@ -68,3 +68,4 @@ def test() = { } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/inline-givens.scala b/tests/neg/inline-givens.scala index 3e388de2ce8b..d8b9d1f2692c 100644 --- a/tests/neg/inline-givens.scala +++ b/tests/neg/inline-givens.scala @@ -3,14 +3,14 @@ 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 - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/main-functions-nameclash.scala b/tests/neg/main-functions-nameclash.scala index 1f9352e1592d..e72f3d2eb0a4 100644 --- a/tests/neg/main-functions-nameclash.scala +++ b/tests/neg/main-functions-nameclash.scala @@ -1,5 +1,7 @@ //> using options -Xfatal-warnings object foo { - @main def foo(x: Int) = () // error: class foo and object foo produce classes that overwrite one another + @main def foo(x: Int) = () // warn: class foo and object foo produce classes that overwrite one another } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/manifest-summoning-b.check b/tests/neg/manifest-summoning-b.check index bb63eebb555f..c364ab4f4a9c 100644 --- a/tests/neg/manifest-summoning-b.check +++ b/tests/neg/manifest-summoning-b.check @@ -1,14 +1,15 @@ --- Error: tests/neg/manifest-summoning-b.scala:3:34 -------------------------------------------------------------------- -3 |val foo = manifest[List[? <: Int]] // error +-- Deprecation Warning: tests/neg/manifest-summoning-b.scala:3:34 ------------------------------------------------------ +3 |val foo = manifest[List[? <: Int]] // warn | ^ | Compiler synthesis of Manifest and OptManifest is deprecated, instead | replace with the type `scala.reflect.ClassTag[List[? <: Int]]`. | Alternatively, consider using the new metaprogramming features of Scala 3, | see https://docs.scala-lang.org/scala3/reference/metaprogramming.html --- Error: tests/neg/manifest-summoning-b.scala:4:41 -------------------------------------------------------------------- -4 |val bar = optManifest[Array[? <: String]] // error +-- Deprecation Warning: tests/neg/manifest-summoning-b.scala:4:41 ------------------------------------------------------ +4 |val bar = optManifest[Array[? <: String]] // warn | ^ | Compiler synthesis of Manifest and OptManifest is deprecated, instead | replace with the type `scala.reflect.ClassTag[Array[? <: String]]`. | Alternatively, consider using the new metaprogramming features of Scala 3, | see https://docs.scala-lang.org/scala3/reference/metaprogramming.html +No warnings can be incurred under -Werror. diff --git a/tests/neg/manifest-summoning-b.scala b/tests/neg/manifest-summoning-b.scala index 6d1b8baff007..83e8b69ead00 100644 --- a/tests/neg/manifest-summoning-b.scala +++ b/tests/neg/manifest-summoning-b.scala @@ -1,4 +1,5 @@ //> using options -Xfatal-warnings -deprecation -val foo = manifest[List[? <: Int]] // error -val bar = optManifest[Array[? <: String]] // error +val foo = manifest[List[? <: Int]] // warn +val bar = optManifest[Array[? <: String]] // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/matchable.scala b/tests/neg/matchable.scala index aaf8234f6d1e..6d8b41f87e55 100644 --- a/tests/neg/matchable.scala +++ b/tests/neg/matchable.scala @@ -4,26 +4,26 @@ def foo[T](x: T): Matchable = println(x.getClass()) // ok println(x.isInstanceOf[Int]) // ok x match - case x: Int => // error: should not be scrutinized + case x: Int => // warn: should not be scrutinized println("int") x - case x: String => // error: should not be scrutinized + case x: String => // warn: should not be scrutinized println("string") x List(x) match - case (x: Int) :: Nil => // error: should not be scrutinized + case (x: Int) :: Nil => // warn: should not be scrutinized println("int") x - case List(x: String) => // error: should not be scrutinized + case List(x: String) => // warn: should not be scrutinized println("string") x - case List(y :: Nil) => // error: should not be scrutinized + case List(y :: Nil) => // warn: should not be scrutinized y :: Nil case _ => - x // error: should not be scrutinized + x // warn: should not be scrutinized @main def Test = val x: Matchable = foo(1) val y: Matchable = foo("hello") assert(x != y) - +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/missing-targetName.scala b/tests/neg/missing-targetName.scala index b5403ac7cb19..8c799c4a19dd 100644 --- a/tests/neg/missing-targetName.scala +++ b/tests/neg/missing-targetName.scala @@ -5,7 +5,8 @@ import scala.annotation.targetName class & { // error @targetName("op") def *(x: Int): Int = ??? // OK - def / (x: Int): Int // error - val frozen_& : Int = ??? // error - object some_??? // error + def / (x: Int): Int // warn + val frozen_& : Int = ??? // warn + object some_??? // warn } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/newline-braces.scala b/tests/neg/newline-braces.scala index afe7731f3095..2aea81c229b2 100644 --- a/tests/neg/newline-braces.scala +++ b/tests/neg/newline-braces.scala @@ -2,7 +2,9 @@ def f: List[Int] = { List(1, 2, 3).map // no newline inserted here in Scala-2 compat mode - { x => // error (migration) + { x => // warn (migration) x + 1 } } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/nonunit-statement.scala b/tests/neg/nonunit-statement.scala index 73c190619187..b96d6b5cfa59 100644 --- a/tests/neg/nonunit-statement.scala +++ b/tests/neg/nonunit-statement.scala @@ -9,38 +9,38 @@ class C { def c = { def improved = Future(42) def stale = Future(27) - improved // error + improved // warn stale } } class D { def d = { class E - new E().toString // error + new E().toString // warn new E().toString * 2 } } class F { import ExecutionContext.Implicits._ - Future(42) // error + Future(42) // warn } // unused template expression uses synthetic method of class case class K(s: String) { - copy() // error + copy() // warn } // mutations returning this are ok class Mutate { val b = ListBuffer.empty[Int] b += 42 // nowarn, returns this.type val xs = List(42) - 27 +: xs // error + 27 +: xs // warn def f(x: Int): this.type = this def g(): Unit = f(42) // nowarn } // some uninteresting expressions may warn for other reasons class WhoCares { - null // error for purity + null // warn for purity ??? // nowarn for impurity } // explicit Unit ascription to opt out of warning, even for funky applies @@ -54,11 +54,11 @@ class Absolution { class Boxed[A](a: A) { def isEmpty = false def foreach[U](f: A => U): Unit = - if (!isEmpty) f(a) // error (if) + if (!isEmpty) f(a) // warn (if) def forall(f: A => Boolean): Unit = if (!isEmpty) { println(".") - f(a) // error (if) + f(a) // warn (if) } def take(p: A => Boolean): Option[A] = { while (isEmpty || !p(a)) () @@ -69,20 +69,20 @@ class Unibranch[A, B] { def runWith[U](action: B => U): A => Boolean = { x => val z = null.asInstanceOf[B] val fellback = false - if (!fellback) action(z) // error (if) + if (!fellback) action(z) // warn (if) !fellback } def f(i: Int): Int = { def g = 17 if (i < 42) { - g // error block statement + g // warn block statement println("uh oh") - g // error (if) + g // warn (if) } while (i < 42) { - g // error + g // warn println("uh oh") - g // error + g // warn } 42 } @@ -92,7 +92,7 @@ class Dibranch { def j: Int = ??? def f(b: Boolean): Int = { // if-expr might have an uninteresting LUB - if (b) { // error, at least one branch looks interesting + if (b) { // warn, at least one branch looks interesting println("true") i } @@ -112,7 +112,7 @@ class Next[A] { class Setting[A] { def set = LinkedHashSet.empty[A] def f(a: A): Unit = { - set += a // error because cannot know whether the `set` was supposed to be consumed or assigned + set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned println(set) } } @@ -122,27 +122,27 @@ class Strung { def iterator = Iterator.empty[String] def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = { val jsb = b.underlying - if (start.length != 0) jsb.append(start) // error (value-discard) + if (start.length != 0) jsb.append(start) // warn (value-discard) val it = iterator if (it.hasNext) { jsb.append(it.next()) while (it.hasNext) { jsb.append(sep) // nowarn (java) - jsb.append(it.next()) // error (value-discard) + jsb.append(it.next()) // warn (value-discard) } } - if (end.length != 0) jsb.append(end) // error (value-discard) + if (end.length != 0) jsb.append(end) // warn (value-discard) b } def f(b: java.lang.StringBuilder, it: Iterator[String]): String = { while (it.hasNext) { b.append("\n") // nowarn (java) - b.append(it.next()) // error (value-discard) + b.append(it.next()) // warn (value-discard) } b.toString } def g(b: java.lang.StringBuilder, it: Iterator[String]): String = { - while (it.hasNext) it.next() // error + while (it.hasNext) it.next() // warn b.toString } } @@ -196,3 +196,4 @@ class Depends { () } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/old-syntax.scala b/tests/neg/old-syntax.scala index 124781d13db2..4f031c96c4c4 100644 --- a/tests/neg/old-syntax.scala +++ b/tests/neg/old-syntax.scala @@ -1,5 +1,6 @@ //> using options -Xfatal-warnings -deprecation -val f = (x: Int) ⇒ x + 1 // error +val f = (x: Int) ⇒ x + 1 // warn -val list = for (n ← List(42)) yield n + 1 // error +val list = for (n ← List(42)) yield n + 1 // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/opaque-match.scala b/tests/neg/opaque-match.scala index 59d0836fb2a3..88c8104506ae 100644 --- a/tests/neg/opaque-match.scala +++ b/tests/neg/opaque-match.scala @@ -12,17 +12,14 @@ def Test[T] = O.x match case _: C => ??? // ok C() match - case _: O.T => ??? // error + case _: O.T => ??? // warn C() match - case _: T => ??? // error + case _: T => ??? // warn (??? : Any) match - case _: List[O.T] => ??? // error + case _: List[O.T] => ??? // warn (??? : Any) match case _: List[O.T @unchecked] => ??? // OK (??? : Any) match - case _: List[T] => ??? // error - - - - + case _: List[T] => ??? // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/ovlazy.scala b/tests/neg/ovlazy.scala index 69078fbd2745..1331589c5d3b 100644 --- a/tests/neg/ovlazy.scala +++ b/tests/neg/ovlazy.scala @@ -4,5 +4,7 @@ class A { val x: Int = 1 } class B extends A { - override lazy val x: Int = 2 // error + override lazy val x: Int = 2 // warn } + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/pureStatement.scala b/tests/neg/pureStatement.scala index 4d2ea1d49b08..72d39ce2ecf6 100644 --- a/tests/neg/pureStatement.scala +++ b/tests/neg/pureStatement.scala @@ -3,16 +3,16 @@ class IOCapability object Test { - "" // error: pure expression does nothing in statement position + "" // warn: pure expression does nothing in statement position locally { - "" // error: pure expression does nothing in statement position + "" // warn: pure expression does nothing in statement position println("") - 42 // error: pure expression does nothing in statement position + 42 // warn: pure expression does nothing in statement position - ((x: Int) => println("hi")) // error: pure expression does nothing in statement position + ((x: Int) => println("hi")) // warn: pure expression does nothing in statement position () } @@ -24,7 +24,7 @@ object Test { implicit val cap: IOCapability = new IOCapability - 2 // error: pure expression does nothing in statement position + 2 // warn: pure expression does nothing in statement position doSideEffects(1) // error: pure expression does nothing in statement position @@ -32,3 +32,4 @@ object Test { broken.foo // no extra error, and no pure expression warning broken.foo() // same } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/quote-simple-hole.scala b/tests/neg/quote-simple-hole.scala index 64e2bcad4862..88af780aa5cd 100644 --- a/tests/neg/quote-simple-hole.scala +++ b/tests/neg/quote-simple-hole.scala @@ -4,14 +4,15 @@ import scala.quoted.Quotes def test(using Quotes) = { val x = '{0} - val y = '{ // error: Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ. + val y = '{ // warn: Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ. $x } val z = '{ - val a = ${ // error: Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ. + val a = ${ // warn: Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ. '{ $y } } } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/refinements-this.scala b/tests/neg/refinements-this.scala index f8d41bd85360..111ce84ffdc8 100644 --- a/tests/neg/refinements-this.scala +++ b/tests/neg/refinements-this.scala @@ -2,4 +2,6 @@ class Outer: type X = { type O = Outer.this.type } // ok - type Y = { type O = this.type } // error + type Y = { type O = this.type } // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/refutable-pattern-binding-messages.check b/tests/neg/refutable-pattern-binding-messages.check index b1b8866e174f..50564f5675d2 100644 --- a/tests/neg/refutable-pattern-binding-messages.check +++ b/tests/neg/refutable-pattern-binding-messages.check @@ -1,48 +1,49 @@ --- Error: tests/neg/refutable-pattern-binding-messages.scala:5:14 ------------------------------------------------------ -5 | val Positive(p) = 5 // error: refutable extractor +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:5:14 ---------------------------------------------------- +5 | val Positive(p) = 5 // warn: refutable extractor | ^^^^^^^^^^^^^^^ | pattern binding uses refutable extractor `Test.Positive` | | If this usage is intentional, this can be communicated by adding `: @unchecked` after the expression, | which may result in a MatchError at runtime. | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:6:14 ------------------------------------------------------ -6 | for Positive(i) <- List(1, 2, 3) do () // error: refutable extractor +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:6:14 ---------------------------------------------------- +6 | for Positive(i) <- List(1, 2, 3) do () // warn: refutable extractor | ^^^^^^^^^^^ | pattern binding uses refutable extractor `Test.Positive` | | If this usage is intentional, this can be communicated by adding the `case` keyword before the full pattern, | which will result in a filtering for expression (using `withFilter`). | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:10:20 ----------------------------------------------------- -10 | val i :: is = List(1, 2, 3) // error: pattern type more specialized +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:10:20 --------------------------------------------------- +10 | val i :: is = List(1, 2, 3) // warn: pattern type more specialized | ^^^^^^^^^^^^^ | pattern's type ::[Int] is more specialized than the right hand side expression's type List[Int] | | If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression, | which may result in a MatchError at runtime. | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:11:11 ----------------------------------------------------- -11 | for ((x: String) <- xs) do () // error: pattern type more specialized +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:11:11 --------------------------------------------------- +11 | for ((x: String) <- xs) do () // warn: pattern type more specialized | ^^^^^^ | pattern's type String is more specialized than the right hand side expression's type AnyRef | | If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern, | which will result in a filtering for expression (using `withFilter`). | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:15:13 ----------------------------------------------------- -15 | for none @ None <- ys do () // error: pattern type does not match +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:15:13 --------------------------------------------------- +15 | for none @ None <- ys do () // warn: pattern type does not match | ^^^^ | pattern's type None.type does not match the right hand side expression's type (x$1 : Option[?]) | | If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern, | which will result in a filtering for expression (using `withFilter`). | This patch can be rewritten automatically under -rewrite -source 3.2-migration. --- Error: tests/neg/refutable-pattern-binding-messages.scala:16:10 ----------------------------------------------------- -16 | val 1 = 2 // error: pattern type does not match +-- Warning: tests/neg/refutable-pattern-binding-messages.scala:16:10 --------------------------------------------------- +16 | val 1 = 2 // warn: pattern type does not match | ^ | pattern's type (1 : Int) does not match the right hand side expression's type (2 : Int) | | If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression, | which may result in a MatchError at runtime. | This patch can be rewritten automatically under -rewrite -source 3.2-migration. +No warnings can be incurred under -Werror. diff --git a/tests/neg/refutable-pattern-binding-messages.scala b/tests/neg/refutable-pattern-binding-messages.scala index c6ae043652c2..bdbacdfa9c03 100644 --- a/tests/neg/refutable-pattern-binding-messages.scala +++ b/tests/neg/refutable-pattern-binding-messages.scala @@ -2,16 +2,17 @@ object Test { // refutable extractor object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } - val Positive(p) = 5 // error: refutable extractor - for Positive(i) <- List(1, 2, 3) do () // error: refutable extractor + val Positive(p) = 5 // warn: refutable extractor + for Positive(i) <- List(1, 2, 3) do () // warn: refutable extractor // more specialized val xs: List[AnyRef] = ??? - val i :: is = List(1, 2, 3) // error: pattern type more specialized - for ((x: String) <- xs) do () // error: pattern type more specialized + val i :: is = List(1, 2, 3) // warn: pattern type more specialized + for ((x: String) <- xs) do () // warn: pattern type more specialized // does not match val ys: List[Option[?]] = ??? - for none @ None <- ys do () // error: pattern type does not match - val 1 = 2 // error: pattern type does not match + for none @ None <- ys do () // warn: pattern type does not match + val 1 = 2 // warn: pattern type does not match } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/rewrite-messages.check b/tests/neg/rewrite-messages.check index 3ee081edbed2..b1aa67845a3f 100644 --- a/tests/neg/rewrite-messages.check +++ b/tests/neg/rewrite-messages.check @@ -1,11 +1,12 @@ --- Error: tests/neg/rewrite-messages.scala:3:18 ------------------------------------------------------------------------ -3 |import scala.util._ // error +-- Migration Warning: tests/neg/rewrite-messages.scala:3:18 ------------------------------------------------------------ +3 |import scala.util._ // warn | ^ | `_` is no longer supported for a wildcard import; use `*` instead | This construct can be rewritten automatically under -rewrite -source future-migration. --- Error: tests/neg/rewrite-messages.scala:7:4 ------------------------------------------------------------------------- -7 | 2 foo 4 // error +-- Deprecation Warning: tests/neg/rewrite-messages.scala:7:4 ----------------------------------------------------------- +7 | 2 foo 4 // warn | ^^^ | Alphanumeric method foo is not declared infix; it should not be used as infix operator. | Instead, use method syntax .foo(...) or backticked identifier `foo`. | The latter can be rewritten automatically under -rewrite -deprecation. +No warnings can be incurred under -Werror. diff --git a/tests/neg/rewrite-messages.scala b/tests/neg/rewrite-messages.scala index 7509682c4baa..25eeea997b8f 100644 --- a/tests/neg/rewrite-messages.scala +++ b/tests/neg/rewrite-messages.scala @@ -1,8 +1,9 @@ //> using options -source:future-migration -deprecation -Werror -import scala.util._ // error +import scala.util._ // warn object Test { extension (x: Int) def foo(y: Int) = x + y - 2 foo 4 // error + 2 foo 4 // warn } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/strict-pattern-bindings-3.2.scala b/tests/neg/strict-pattern-bindings-3.2.scala index d7db6cd165e4..c678e2ebe93a 100644 --- a/tests/neg/strict-pattern-bindings-3.2.scala +++ b/tests/neg/strict-pattern-bindings-3.2.scala @@ -6,32 +6,33 @@ object Test: // from filtering-fors.scala val xs: List[AnyRef] = ??? - for ((x: String) <- xs) do () // error - for (y@ (x: String) <- xs) do () // error - for ((x, y) <- xs) do () // error + for ((x: String) <- xs) do () // warn + for (y@ (x: String) <- xs) do () // warn + for ((x, y) <- xs) do () // warn - for ((x: String) <- xs if x.isEmpty) do () // error - for ((x: String) <- xs; y = x) do () // error - for ((x: String) <- xs; (y, z) <- xs) do () // error // error - for (case (x: String) <- xs; (y, z) <- xs) do () // error - for ((x: String) <- xs; case (y, z) <- xs) do () // error + for ((x: String) <- xs if x.isEmpty) do () // warn + for ((x: String) <- xs; y = x) do () // warn + for ((x: String) <- xs; (y, z) <- xs) do () // warn // warn + for (case (x: String) <- xs; (y, z) <- xs) do () // warn + for ((x: String) <- xs; case (y, z) <- xs) do () // warn val pairs: List[AnyRef] = List((1, 2), "hello", (3, 4)) - for ((x, y) <- pairs) yield (y, x) // error + for ((x, y) <- pairs) yield (y, x) // warn // from unchecked-patterns.scala - val y :: ys = List(1, 2, 3) // error - val (1, c) = (1, 2) // error - val 1 *: cs = 1 *: Tuple() // error + val y :: ys = List(1, 2, 3) // warn + val (1, c) = (1, 2) // warn + val 1 *: cs = 1 *: Tuple() // warn - val (_: Int | _: AnyRef) = ??? : AnyRef // error + val (_: Int | _: AnyRef) = ??? : AnyRef // warn - val 1 = 2 // error + val 1 = 2 // warn object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } object Always1 { def unapply(i: Int): Some[Int] = Some(i) } object Pair { def unapply(t: (Int, Int)): t.type = t } object Triple { def unapply(t: (Int, Int, Int)): (Int, Int, Int) = t } - val Positive(p) = 5 // error - val Some(s1) = Option(1) // error + val Positive(p) = 5 // warn + val Some(s1) = Option(1) // warn +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/structural-2.scala b/tests/neg/structural-2.scala index 3613d6073e34..85fac55c08a5 100644 --- a/tests/neg/structural-2.scala +++ b/tests/neg/structural-2.scala @@ -69,7 +69,8 @@ object Test { package p6 { class Refinements { - val y: { val x: T; type T } // error: deprecated warning: illegal forward reference in refinement; now illegal + val y: { val x: T; type T } // warn: deprecated warning: illegal forward reference in refinement; now illegal } } +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/supertraits-b.scala b/tests/neg/supertraits-b.scala index 78854537974e..b56059b4abbb 100644 --- a/tests/neg/supertraits-b.scala +++ b/tests/neg/supertraits-b.scala @@ -16,20 +16,21 @@ object Test: choose0(a, b) match case _: TA => ??? - case _: TB => ??? // error: unreachable + case _: TB => ??? // warn: unreachable choose1(a, b) match case _: TA => ??? - case _: TB => ??? // error: unreachable + case _: TB => ??? // warn: unreachable choose2(a, b) match case _: TB => ??? - case _: TA => ??? // error: unreachable + case _: TA => ??? // warn: unreachable choose3(a, b) match case _: Product => ??? - case _: TA => ??? // error: unreachable + case _: TA => ??? // warn: unreachable choose4(a, b) match case _: (TA & TB) => ??? - case _: Product => ??? // error: unreachable \ No newline at end of file + case _: Product => ??? // warn: unreachable +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/switches.scala b/tests/neg/switches.scala index d405f8185706..f662a1f694ca 100644 --- a/tests/neg/switches.scala +++ b/tests/neg/switches.scala @@ -38,7 +38,7 @@ object Main { // multiple annotations are processed correctly // thinks a val in an object is constant... so naive - def fail1(c: Char) = (c: @switch @unchecked) match { // error: Could not emit switch for @switch annotated match + def fail1(c: Char) = (c: @switch @unchecked) match { // warn: Could not emit switch for @switch annotated match case 'A' => true case 'B' => true case Other.C1 => true @@ -46,7 +46,7 @@ object Main { } // more naivete - def fail2(c: Char) = (c: @unchecked @switch) match { // error: Could not emit switch for @switch annotated match + def fail2(c: Char) = (c: @unchecked @switch) match { // warn: Could not emit switch for @switch annotated match case 'A' => true case 'B' => true case Other.C3 => true @@ -69,12 +69,12 @@ object Main { case _ => -1 } - def fail3(x: Any) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail3(x: Any) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case 1 | 2 | 3 => true case _ => false } - def fail4(x: AnyVal) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail4(x: AnyVal) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case 1 | 2 | 3 => true case _ => false } @@ -82,7 +82,7 @@ object Main { case class IntAnyVal(x: Int) extends AnyVal val Ten = IntAnyVal(10) - def fail5(x: IntAnyVal) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail5(x: IntAnyVal) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case IntAnyVal(1) => 0 case Ten => 1 case IntAnyVal(100) => 2 @@ -92,7 +92,7 @@ object Main { // the generated lookupswitch covers only a subset of the cases final val One = IntAnyVal(1) - def fail6(x: IntAnyVal) = (x: @switch) match { // error: Could not emit switch for @switch annotated match + def fail6(x: IntAnyVal) = (x: @switch) match { // warn: Could not emit switch for @switch annotated match case One => 0 case IntAnyVal(10) => 1 case IntAnyVal(100) => 2 @@ -100,3 +100,4 @@ object Main { case IntAnyVal(10000) => 4 } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/symbolic-packages.check b/tests/neg/symbolic-packages.check index 8e9b7e114829..4a0e99f22a85 100644 --- a/tests/neg/symbolic-packages.check +++ b/tests/neg/symbolic-packages.check @@ -1,16 +1,17 @@ --- Error: tests/neg/symbolic-packages.scala:3:8 ------------------------------------------------------------------------ -3 |package `with spaces` { // error +-- Warning: tests/neg/symbolic-packages.scala:3:8 ---------------------------------------------------------------------- +3 |package `with spaces` { // warn | ^^^^^^^^^^^^^ | The package name `with spaces` will be encoded on the classpath, and can lead to undefined behaviour. --- Error: tests/neg/symbolic-packages.scala:7:10 ----------------------------------------------------------------------- -7 |package +.* { // error // error +-- Warning: tests/neg/symbolic-packages.scala:7:10 --------------------------------------------------------------------- +7 |package +.* { // warn // warn | ^ | The package name `*` will be encoded on the classpath, and can lead to undefined behaviour. --- Error: tests/neg/symbolic-packages.scala:7:8 ------------------------------------------------------------------------ -7 |package +.* { // error // error +-- Warning: tests/neg/symbolic-packages.scala:7:8 ---------------------------------------------------------------------- +7 |package +.* { // warn // warn | ^ | The package name `+` will be encoded on the classpath, and can lead to undefined behaviour. --- Error: tests/neg/symbolic-packages.scala:11:16 ---------------------------------------------------------------------- -11 |package object `mixed_*` { // error +-- Warning: tests/neg/symbolic-packages.scala:11:16 -------------------------------------------------------------------- +11 |package object `mixed_*` { // warn | ^^^^^^^ | The package name `mixed_*` will be encoded on the classpath, and can lead to undefined behaviour. +No warnings can be incurred under -Werror. diff --git a/tests/neg/symbolic-packages.scala b/tests/neg/symbolic-packages.scala index 12719d027b4c..557fb06f68a9 100644 --- a/tests/neg/symbolic-packages.scala +++ b/tests/neg/symbolic-packages.scala @@ -1,13 +1,14 @@ //> using options -Xfatal-warnings -package `with spaces` { // error +package `with spaces` { // warn class Foo } -package +.* { // error // error +package +.* { // warn // warn class Bar } -package object `mixed_*` { // error +package object `mixed_*` { // warn class Baz } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/t3235-minimal.check b/tests/neg/t3235-minimal.check index 83c287f85bc0..989af71b5355 100644 --- a/tests/neg/t3235-minimal.check +++ b/tests/neg/t3235-minimal.check @@ -1,16 +1,17 @@ --- Error: tests/neg/t3235-minimal.scala:5:21 --------------------------------------------------------------------------- -5 | assert(123456789.round == 123456789) // error +-- Deprecation Warning: tests/neg/t3235-minimal.scala:5:21 ------------------------------------------------------------- +5 | assert(123456789.round == 123456789) // warn | ^^^^^^^^^^^^^^^ |method round in class RichInt is deprecated since 2.11.0: this is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value? --- Error: tests/neg/t3235-minimal.scala:6:16 --------------------------------------------------------------------------- -6 | assert(math.round(123456789) == 123456789) // error +-- Deprecation Warning: tests/neg/t3235-minimal.scala:6:16 ------------------------------------------------------------- +6 | assert(math.round(123456789) == 123456789) // warn | ^^^^^^^^^^ |method round in package scala.math is deprecated since 2.11.0: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value? --- Error: tests/neg/t3235-minimal.scala:7:32 --------------------------------------------------------------------------- -7 | assert(1234567890123456789L.round == 1234567890123456789L) // error +-- Deprecation Warning: tests/neg/t3235-minimal.scala:7:32 ------------------------------------------------------------- +7 | assert(1234567890123456789L.round == 1234567890123456789L) // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |method round in class RichLong is deprecated since 2.11.0: this is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value? --- Error: tests/neg/t3235-minimal.scala:8:16 --------------------------------------------------------------------------- -8 | assert(math.round(1234567890123456789L) == 1234567890123456789L) // error +-- Deprecation Warning: tests/neg/t3235-minimal.scala:8:16 ------------------------------------------------------------- +8 | assert(math.round(1234567890123456789L) == 1234567890123456789L) // warn | ^^^^^^^^^^ |method round in package scala.math is deprecated since 2.11.0: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value? +No warnings can be incurred under -Werror. diff --git a/tests/neg/t3235-minimal.scala b/tests/neg/t3235-minimal.scala index f65ee13f87f5..27448da4b80b 100644 --- a/tests/neg/t3235-minimal.scala +++ b/tests/neg/t3235-minimal.scala @@ -2,9 +2,10 @@ object Test { def main(args: Array[String]): Unit = { - assert(123456789.round == 123456789) // error - assert(math.round(123456789) == 123456789) // error - assert(1234567890123456789L.round == 1234567890123456789L) // error - assert(math.round(1234567890123456789L) == 1234567890123456789L) // error + assert(123456789.round == 123456789) // warn + assert(math.round(123456789) == 123456789) // warn + assert(1234567890123456789L.round == 1234567890123456789L) // warn + assert(math.round(1234567890123456789L) == 1234567890123456789L) // warn } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/t5830.scala b/tests/neg/t5830.scala index 947b7bac4a22..dc6e51ed1f3d 100644 --- a/tests/neg/t5830.scala +++ b/tests/neg/t5830.scala @@ -5,7 +5,9 @@ import scala.annotation.switch class Test { def unreachable(ch: Char) = (ch: @switch) match { case 'a' => println("b") // ok - case 'a' => println("b") // error: unreachable case + case 'a' => println("b") // warn: unreachable case case 'c' => } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/type-test-paths-2.scala b/tests/neg/type-test-paths-2.scala index 4bba2f87416e..5a68c1607bfd 100644 --- a/tests/neg/type-test-paths-2.scala +++ b/tests/neg/type-test-paths-2.scala @@ -29,15 +29,16 @@ object Test { val r2: R = RI r1.n match { - case n: r2.Nat => // error: the type test for Test.r2.Nat cannot be checked at runtime - case n: r1.Idx => // error: the type test for Test.r1.Idx cannot be checked at runtime + case n: r2.Nat => // warn: the type test for Test.r2.Nat cannot be checked at runtime + case n: r1.Idx => // warn: the type test for Test.r1.Idx cannot be checked at runtime case n: r1.Succ => // Ok case n: r1.Nat => // Ok } r1.one match { - case n: r2.Nat => // error: the type test for Test.r2.Nat cannot be checked at runtime - case n: r1.Idx => // error: the type test for Test.r1.Idx cannot be checked at runtime + case n: r2.Nat => // warn: the type test for Test.r2.Nat cannot be checked at runtime + case n: r1.Idx => // warn: the type test for Test.r1.Idx cannot be checked at runtime case n: r1.Nat => // Ok } } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/type-test-paths.scala b/tests/neg/type-test-paths.scala index 324ed43ba7fa..e8c9d2879e6d 100644 --- a/tests/neg/type-test-paths.scala +++ b/tests/neg/type-test-paths.scala @@ -8,7 +8,7 @@ object Test { val p2: T = T1 (p1.y: p1.X) match { - case x: p2.Y => // error: unchecked + case x: p2.Y => // warn: unchecked case x: p1.Y => case _ => } @@ -37,3 +37,5 @@ object T1 extends T { } } + +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/type-test-syntesize-b.scala b/tests/neg/type-test-syntesize-b.scala index 79be9357387e..ab3b970f79f8 100644 --- a/tests/neg/type-test-syntesize-b.scala +++ b/tests/neg/type-test-syntesize-b.scala @@ -19,9 +19,9 @@ object Test { test[Any, Array[Int]] test[Seq[Int], List[Int]] - test[Any, Some[Int]] // error - test[Any, a.X] // error - test[a.X, a.Y] // error + test[Any, Some[Int]] // warn + test[Any, a.X] // warn + test[a.X, a.Y] // warn } @@ -29,3 +29,4 @@ class A { type X type Y <: X } +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/unchecked-patterns.scala b/tests/neg/unchecked-patterns.scala index db304a2f1875..7e6c4de76a50 100644 --- a/tests/neg/unchecked-patterns.scala +++ b/tests/neg/unchecked-patterns.scala @@ -5,23 +5,24 @@ object Test { val (y1: Some[Int]) = Some(1): Option[Int] @unchecked // OK val y2: Some[Int] @unchecked = Some(1): Option[Int] // error - val x :: xs = List(1, 2, 3) // error - val (1, c) = (1, 2) // error - val 1 *: cs = 1 *: Tuple() // error + val x :: xs = List(1, 2, 3) // warn + val (1, c) = (1, 2) // warn + val 1 *: cs = 1 *: Tuple() // warn - val (_: Int | _: AnyRef) = ??? : AnyRef // error + val (_: Int | _: AnyRef) = ??? : AnyRef // warn - val 1 = 2 // error + val 1 = 2 // warn object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) } object Always1 { def unapply(i: Int): Some[Int] = Some(i) } object Pair { def unapply(t: (Int, Int)): t.type = t } object Triple { def unapply(t: (Int, Int, Int)): (Int, Int, Int) = t } - val Positive(p) = 5 // error - val Some(s1) = Option(1) // error + val Positive(p) = 5 // warn + val Some(s1) = Option(1) // warn val Some(s2) = Some(1) // OK val Always1(p1) = 5 // OK val Pair(t1, t2) = (5, 5) // OK val Triple(u1, u2, u3) = (5, 5, 5) // OK -} \ No newline at end of file +} +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/warn-value-discard.check b/tests/neg/warn-value-discard.check index ba43c743709f..f803179d1c3a 100644 --- a/tests/neg/warn-value-discard.check +++ b/tests/neg/warn-value-discard.check @@ -1,20 +1,21 @@ --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:27:36 ---------------------------------------------- -27 | mutable.Set.empty[String].remove("") // error +-- [E175] Potential Issue Warning: tests/neg/warn-value-discard.scala:27:36 -------------------------------------------- +27 | mutable.Set.empty[String].remove("") // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | discarded non-Unit value of type Boolean --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:39:41 ---------------------------------------------- -39 | mutable.Set.empty[String].subtractOne("") // error +-- [E175] Potential Issue Warning: tests/neg/warn-value-discard.scala:39:41 -------------------------------------------- +39 | mutable.Set.empty[String].subtractOne("") // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | discarded non-Unit value of type scala.collection.mutable.Set[String] --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:59:4 ----------------------------------------------- -59 | mutable.Set.empty[String] += "" // error +-- [E175] Potential Issue Warning: tests/neg/warn-value-discard.scala:59:4 --------------------------------------------- +59 | mutable.Set.empty[String] += "" // warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | discarded non-Unit value of type scala.collection.mutable.Set[String] --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:15:35 ---------------------------------------------- -15 | firstThing().map(_ => secondThing()) // error +-- [E175] Potential Issue Warning: tests/neg/warn-value-discard.scala:15:35 -------------------------------------------- +15 | firstThing().map(_ => secondThing()) // warn | ^^^^^^^^^^^^^ | discarded non-Unit value of type Either[Failed, Unit] --- [E175] Potential Issue Error: tests/neg/warn-value-discard.scala:18:35 ---------------------------------------------- -18 | firstThing().map(_ => secondThing()) // error +-- [E175] Potential Issue Warning: tests/neg/warn-value-discard.scala:18:35 -------------------------------------------- +18 | firstThing().map(_ => secondThing()) // warn | ^^^^^^^^^^^^^ | discarded non-Unit value of type Either[Failed, Unit] +No warnings can be incurred under -Werror. diff --git a/tests/neg/warn-value-discard.scala b/tests/neg/warn-value-discard.scala index fb01fdeda384..5bfb81b2fb65 100644 --- a/tests/neg/warn-value-discard.scala +++ b/tests/neg/warn-value-discard.scala @@ -12,10 +12,10 @@ def secondThing(): Either[Failed, Unit] = Left(Failed("whoops you should have flatMapped me")) def singleExpr(): Either[Failed, Unit] = - firstThing().map(_ => secondThing()) // error + firstThing().map(_ => secondThing()) // warn def block(): Either[Failed, Unit] = { - firstThing().map(_ => secondThing()) // error + firstThing().map(_ => secondThing()) // warn } class ValueDiscardTest: @@ -24,7 +24,7 @@ class ValueDiscardTest: def remove(): Unit = // Set#remove returns a Boolean, not this.type // --> Warning - mutable.Set.empty[String].remove("") // error + mutable.Set.empty[String].remove("") // warn // TODO IMHO we don't need to support this, // as it's just as easy to add a @nowarn annotation as a Unit ascription @@ -36,7 +36,7 @@ class ValueDiscardTest: // - Set#subtractOne returns this.type // - receiver is not a field or a local variable (not quite sure what you'd call it) // --> Warning - mutable.Set.empty[String].subtractOne("") // error + mutable.Set.empty[String].subtractOne("") // warn def mutateLocalVariable(): Unit = { // - Set#subtractOne returns this.type @@ -56,7 +56,7 @@ class ValueDiscardTest: // - += returns this.type // - receiver is not a field or a local variable // --> Warning - mutable.Set.empty[String] += "" // error + mutable.Set.empty[String] += "" // warn def assignmentOperatorLocalVariable(): Unit = // - += returns this.type @@ -64,3 +64,4 @@ class ValueDiscardTest: // --> No warning val s: mutable.Set[String] = mutable.Set.empty[String] s += "" +// nopos-error: No warnings can be incurred under -Werror. \ No newline at end of file diff --git a/tests/neg/with-type-operator-future-migration.check b/tests/neg/with-type-operator-future-migration.check index 29ea1d5aad4c..4dbcd993f242 100644 --- a/tests/neg/with-type-operator-future-migration.check +++ b/tests/neg/with-type-operator-future-migration.check @@ -1,7 +1,8 @@ --- [E003] Syntax Error: tests/neg/with-type-operator-future-migration.scala:5:13 --------------------------------------- -5 |def foo: Int with String = ??? // error +-- [E003] Syntax Migration Warning: tests/neg/with-type-operator-future-migration.scala:5:13 --------------------------- +5 |def foo: Int with String = ??? // warn | ^ | with as a type operator has been deprecated; use & instead | This construct can be rewritten automatically under -rewrite -source future-migration. | | longer explanation available when compiling with `-explain` +No warnings can be incurred under -Werror. diff --git a/tests/neg/with-type-operator-future-migration.scala b/tests/neg/with-type-operator-future-migration.scala index 3ed2e3a8f067..dac924603636 100644 --- a/tests/neg/with-type-operator-future-migration.scala +++ b/tests/neg/with-type-operator-future-migration.scala @@ -2,4 +2,6 @@ import scala.language.`future-migration` -def foo: Int with String = ??? // error +def foo: Int with String = ??? // warn + +// nopos-error: No warnings can be incurred under -Werror. diff --git a/tests/neg/xfatalWarnings.scala b/tests/neg/xfatalWarnings.scala index 3f49e159cbc4..13763bf3b48d 100644 --- a/tests/neg/xfatalWarnings.scala +++ b/tests/neg/xfatalWarnings.scala @@ -3,7 +3,7 @@ object xfatalWarnings { val opt:Option[String] = Some("test") - opt match { // error when running with -Xfatal-warnings + opt match { // warn case None => } @@ -11,3 +11,6 @@ object xfatalWarnings { while (true) {} // should be ok. no "pure expression does nothing in statement position" issued. } } + +// When running with fatal warnings: +// nopos-error: No warnings can be incurred under -Werror.