Skip to content

Commit dd9808a

Browse files
committed
Adjusted tests
1 parent 4aa8e40 commit dd9808a

File tree

178 files changed

+1020
-805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+1020
-805
lines changed

tests/neg-deep-subtype/1828.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
class Test {
44
def remove[S](a: S | Int, f: Int => S):S = a match {
5-
case a: S => a // error
5+
case a: S => a // warn
66
case a: Int => f(a)
77
}
88

99
val t: Int | String = 5
1010
val t1 = remove[String](t, _.toString)
1111
}
12+
13+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/3324b.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
class C[T] {
44
val x: Any = ???
5-
if (x.isInstanceOf[List[String]]) // error: unchecked
6-
if (x.isInstanceOf[T]) // error: unchecked
5+
if (x.isInstanceOf[List[String]]) // warn: unchecked
6+
if (x.isInstanceOf[T]) // warn: unchecked
77
x match {
8-
case x: List[String] => // error: unchecked
9-
case x: T => // error: unchecked
8+
case x: List[String] => // warn: unchecked
9+
case x: T => // warn: unchecked
1010
}
1111
}
12+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/3324f.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class D[T]
55

66
class Test {
77
def foo[T](x: C[T]) = x match {
8-
case _: D[T] => // error
9-
case _: C[Int] => // error
8+
case _: D[T] => // warn
9+
case _: C[Int] => // warn
1010
}
11-
}
11+
}
12+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/3324g.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ class Test {
66
class C[T] extends B[Any] with A[T]
77

88
def foo[T](c: C[T]): Unit = c match {
9-
case _: B[T] => // error
9+
case _: B[T] => // warn
1010
}
1111

1212
def bar[T](b: B[T]): Unit = b match {
1313
case _: A[T] =>
1414
}
1515

1616
def quux[T](a: A[T]): Unit = a match {
17-
case _: B[T] => // error!!
17+
case _: B[T] => // warn!!
1818
}
1919

2020
quux(new C[Int])
2121
}
22+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/JavaSeqLiteral.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Test1 {
1010
class DummyTree extends JavaSeqLiteral[Any]
1111

1212
def foo1(tree: Tree[Type]) =
13-
tree.isInstanceOf[JavaSeqLiteral[Type]] // error
13+
tree.isInstanceOf[JavaSeqLiteral[Type]] // warn
1414

1515
foo1(new DummyTree)
1616
}
@@ -28,4 +28,6 @@ object Test2 {
2828
tree.isInstanceOf[JavaSeqLiteral[Type]]
2929

3030
foo1(new DummyTree)
31-
}
31+
}
32+
33+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/conditionalWarnings.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ object Test {
55

66
given Conversion[String, Int] = _.length
77

8-
foo // error
8+
foo // warn
99

1010
val x: Int = "abc"
1111
// OK, since -feature warnings are not enabled.
1212
// The program compiles with final line
1313
// there was 1 feature warning; re-run with -feature for details
14-
// nopos-error
14+
// nopos-warn
1515
}
16+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/gadt.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ class Test {
88
class D extends C
99

1010
def quux(a: A[C]): Unit = a match {
11-
case _: B[C] => // error!!
11+
case _: B[C] => // warn
1212
}
1313

1414
quux(new B[D])
15-
}
15+
}
16+
17+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/html.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ object HTML:
1212
attrs.filter(_ != Nil).foreach{
1313
case s: Seq[AppliedAttr] =>
1414
s.foreach(sb.append(" ").append)
15-
case s: Seq[Int] => // error
15+
case s: Seq[Int] => // warn
1616
case e: AppliedAttr =>
1717
sb.append(" ").append(e)
1818
}
1919
sb
2020
}
21+
22+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/i3324.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
class Foo {
44
def foo(x: Any): Boolean =
5-
x.isInstanceOf[List[String]] // error
5+
x.isInstanceOf[List[String]] // warn
66
}
7+
8+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/i4297.scala

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ class Test {
44
def test[X <: Option[Int]](x: X) = x.isInstanceOf[Some[Int]]
55
def test1[Y <: Int, X <: Option[Y]](x: X) = x.isInstanceOf[Some[Int]]
66
def test2(x: Any) = x.isInstanceOf[Function1[Nothing, _]]
7-
def test3a(x: Any) = x.isInstanceOf[Function1[Any, _]] // error
8-
def test3b(x: Any) = x.isInstanceOf[Function1[Int, _]] // error
9-
def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, _]] // error
10-
def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // error
11-
def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // error
7+
def test3a(x: Any) = x.isInstanceOf[Function1[Any, _]] // warn
8+
def test3b(x: Any) = x.isInstanceOf[Function1[Int, _]] // warn
9+
def test4[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, _]] // warn
10+
def test5[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Unit]] // warn
11+
def test6[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[Int, Any]] // warn
1212
def test7[Y <: Int, X <: Function1[Y, Unit]](x: X) = x.isInstanceOf[Function1[_, Unit]]
1313
}
14+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/or-type-trees.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test1 {
99

1010
def foo2(myTree: Tree | (Context => Tree)) =
1111
myTree match
12-
case treeFn: (Context => Tree) => // error
12+
case treeFn: (Context => Tree) => // warn
1313
case _ =>
1414

1515
def foo3(myTree: Tree | (Context => Tree)) =
@@ -25,16 +25,17 @@ object Test2 {
2525
trait Type
2626

2727
def foo1(myTree: Tree[Type] | (Context => Tree[Type])) =
28-
println(myTree.isInstanceOf[Tree[Type]]) // error
28+
println(myTree.isInstanceOf[Tree[Type]]) // warn
2929
/* class DummyTree extends Tree[Nothing] with (Context => Tree[Type]) */
3030

3131
def foo2(myTree: Tree[Type] | (Context => Tree[Type])) =
3232
myTree match
33-
case treeFn: (Context => Tree[Type]) => // error
33+
case treeFn: (Context => Tree[Type]) => // warn
3434
case _ =>
3535

3636
def foo3(myTree: Tree[Type] | (Context => Tree[Type])) =
3737
myTree match
3838
case treeFn: (_ => _) => // ok
3939
case _ =>
40-
}
40+
}
41+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/refined-types.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def bl(x: AA) = x.isInstanceOf[BL] // was: the type test for BL cannot be checke
1818
def bu(x: AA) = x.isInstanceOf[BU] // was: the type test for BU cannot be checked at runtime
1919

2020
// but static knowledge of only one bound makes checking against an alias unchecked:
21-
def al_ba(x: AL) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime
22-
def au_ba(x: AU) = x.isInstanceOf[BA] // error: the type test for BA cannot be checked at runtime
23-
def al_bu(x: AL) = x.isInstanceOf[BU] // error: the type test for BU cannot be checked at runtime
24-
def au_bl(x: AU) = x.isInstanceOf[BL] // error: the type test for BL cannot be checked at runtime
21+
def al_ba(x: AL) = x.isInstanceOf[BA] // warn: the type test for BA cannot be checked at runtime
22+
def au_ba(x: AU) = x.isInstanceOf[BA] // warn: the type test for BA cannot be checked at runtime
23+
def al_bu(x: AL) = x.isInstanceOf[BU] // warn: the type test for BU cannot be checked at runtime
24+
def au_bl(x: AU) = x.isInstanceOf[BL] // warn: the type test for BL cannot be checked at runtime
25+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/t2755.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object Test {
1919
case x: Array[String] => x.size
2020
case x: Array[AnyRef] => 5
2121
case x: Array[_] => 6
22-
case _ => 7 // error: only null is matched
22+
case _ => 7 // warn: only null is matched
2323
}
2424
def f3[T](a: Array[T]) = a match {
2525
case x: Array[Int] => x(0)
@@ -28,7 +28,7 @@ object Test {
2828
case x: Array[String] => x.size
2929
case x: Array[AnyRef] => 5
3030
case x: Array[_] => 6
31-
case _ => 7 // error: only null is matched
31+
case _ => 7 // warn: only null is matched
3232
}
3333

3434

@@ -58,3 +58,4 @@ object Test {
5858
println(f3(null))
5959
}
6060
}
61+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg-deep-subtype/type-lambda.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ object Test {
1010
}
1111

1212
def bar(x: ([X] =>> A[X])[Any]) = x match {
13-
case x: ([X] =>> B[Nothing])[Any] => // error
13+
case x: ([X] =>> B[Nothing])[Any] => // warn
1414
case _ =>
1515
}
1616
}
17+
18+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg/14034b.scala

+9-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
@deprecated trait Exp
44
@deprecated val exp = 1
55

6-
def test1 = exp // error
7-
def test2(a: Exp) = () // error
6+
def test1 = exp // warn
7+
def test2(a: Exp) = () // warn
88

9-
type Foo0 = Exp // error
10-
type Foo = Option[Exp] // error
11-
type Bar = Option[exp.type] // error
12-
type Baz = Exp | Int // error
9+
type Foo0 = Exp // warn
10+
type Foo = Option[Exp] // warn
11+
type Bar = Option[exp.type] // warn
12+
type Baz = Exp | Int // warn
1313
type Quux = [X] =>> X match
14-
case Exp => Int // error
15-
type Quuz[A <: Exp] = Int // error
14+
case Exp => Int // warn
15+
type Quuz[A <: Exp] = Int // warn
16+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg/15981.check

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
-- [E092] Pattern Match Error: tests/neg/15981.scala:4:45 --------------------------------------------------------------
2-
4 | override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // error
1+
-- [E092] Pattern Match Unchecked Warning: tests/neg/15981.scala:4:45 --------------------------------------------------
2+
4 | override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn
33
| ^^^
44
| the type test for PosInt cannot be checked at runtime because it's a local class
55
|
66
| longer explanation available when compiling with `-explain`
7+
No warnings can be incurred under -Werror.

tests/neg/15981.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//> using options -Werror
22
val _ = locally{
33
sealed abstract class PosInt(val value: Int) {
4-
override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // error
4+
override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn
55
}
66
}
7+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg/17284.check

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- [E187] Potential Issue Error: tests/neg/17284.scala:4:6 -------------------------------------------------------------
2-
4 | 451.synchronized {} // error
1+
-- [E187] Potential Issue Warning: tests/neg/17284.scala:4:6 -----------------------------------------------------------
2+
4 | 451.synchronized {} // warn
33
| ^^^^^^^^^^^^^^^^
44
| Suspicious synchronized call on boxed class
55
|---------------------------------------------------------------------------------------------------------------------
@@ -8,8 +8,8 @@
88
| You called the synchronized method on a boxed primitive. This might not be what
99
| you intended.
1010
---------------------------------------------------------------------------------------------------------------------
11-
-- [E187] Potential Issue Error: tests/neg/17284.scala:8:4 -------------------------------------------------------------
12-
8 | x.synchronized {} // error
11+
-- [E187] Potential Issue Warning: tests/neg/17284.scala:8:4 -----------------------------------------------------------
12+
8 | x.synchronized {} // warn
1313
| ^^^^^^^^^^^^^^
1414
| Suspicious synchronized call on boxed class
1515
|---------------------------------------------------------------------------------------------------------------------
@@ -18,8 +18,8 @@
1818
| You called the synchronized method on a boxed primitive. This might not be what
1919
| you intended.
2020
---------------------------------------------------------------------------------------------------------------------
21-
-- [E187] Potential Issue Error: tests/neg/17284.scala:11:7 ------------------------------------------------------------
22-
11 | true.synchronized {} // error
21+
-- [E187] Potential Issue Warning: tests/neg/17284.scala:11:7 ----------------------------------------------------------
22+
11 | true.synchronized {} // warn
2323
| ^^^^^^^^^^^^^^^^^
2424
| Suspicious synchronized call on boxed class
2525
|--------------------------------------------------------------------------------------------------------------------
@@ -28,3 +28,4 @@
2828
| You called the synchronized method on a boxed primitive. This might not be what
2929
| you intended.
3030
--------------------------------------------------------------------------------------------------------------------
31+
No warnings can be incurred under -Werror.

tests/neg/17284.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//> using options -Werror -explain
22

33
def test =
4-
451.synchronized {} // error
4+
451.synchronized {} // warn
55

66
def test2 =
77
val x: Integer = 451
8-
x.synchronized {} // error
8+
x.synchronized {} // warn
99

1010
def test3 =
11-
true.synchronized {} // error
11+
true.synchronized {} // warn
1212

1313
def test4 =
1414
true.hashCode() // success
15+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg/18493.check

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
-- [E030] Match case Unreachable Error: tests/neg/18493.scala:6:9 ------------------------------------------------------
2-
6 | case "abc" => // error
1+
-- [E030] Match case Unreachable Warning: tests/neg/18493.scala:6:9 ----------------------------------------------------
2+
6 | case "abc" => // warn
33
| ^^^^^
44
| Unreachable case
5-
-- [E030] Match case Unreachable Error: tests/neg/18493.scala:12:9 -----------------------------------------------------
6-
12 | case "abc" => // error
5+
-- [E030] Match case Unreachable Warning: tests/neg/18493.scala:12:9 ---------------------------------------------------
6+
12 | case "abc" => // warn
77
| ^^^^^
88
| Unreachable case
9+
No warnings can be incurred under -Werror.

tests/neg/18493.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ object PartialFunctionNoWarning {
33
// nice warning
44
"abc" match {
55
case "abc" =>
6-
case "abc" => // error
6+
case "abc" => // warn
77
}
88

99
// no warnings
1010
val pf: PartialFunction[String, Unit] = {
1111
case "abc" =>
12-
case "abc" => // error
12+
case "abc" => // warn
1313
}
14-
}
14+
}
15+
// nopos-error: No warnings can be incurred under -Werror.

tests/neg/IsInstanceOfClassTag2.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object IsInstanceOfClassTag {
1111
}
1212

1313
def main(args: Array[String]): Unit = {
14-
safeCast[List[String]](List[Int](1)) match { // error
14+
safeCast[List[String]](List[Int](1)) match { // warn
1515
case None =>
1616
case Some(xs) =>
1717
}
@@ -22,3 +22,5 @@ object IsInstanceOfClassTag {
2222
}
2323
}
2424
}
25+
26+
// nopos-error: No warnings can be incurred under -Werror.

0 commit comments

Comments
 (0)