Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Move warn tests from tests/neg to tests/warn: Batch 2" to LTS #20844

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions tests/neg-deep-subtype/3324b.scala

This file was deleted.

11 changes: 0 additions & 11 deletions tests/neg-deep-subtype/3324f.scala

This file was deleted.

15 changes: 0 additions & 15 deletions tests/neg/14034b.scala

This file was deleted.

14 changes: 0 additions & 14 deletions tests/neg/17284.scala

This file was deleted.

8 changes: 0 additions & 8 deletions tests/neg/18493.check

This file was deleted.

11 changes: 0 additions & 11 deletions tests/neg/avoid-warn-deprecation.scala

This file was deleted.

14 changes: 0 additions & 14 deletions tests/neg/gadt-contradictory-pattern.scala

This file was deleted.

5 changes: 0 additions & 5 deletions tests/neg/main-functions-nameclash.scala

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg/manifest-summoning-b.scala

This file was deleted.

29 changes: 0 additions & 29 deletions tests/neg/matchable.scala

This file was deleted.

5 changes: 0 additions & 5 deletions tests/neg/old-syntax.scala

This file was deleted.

8 changes: 0 additions & 8 deletions tests/neg/ovlazy.scala

This file was deleted.

17 changes: 0 additions & 17 deletions tests/neg/quote-simple-hole.scala

This file was deleted.

8 changes: 0 additions & 8 deletions tests/neg/rewrite-messages.scala

This file was deleted.

37 changes: 0 additions & 37 deletions tests/neg/strict-pattern-bindings-3.2.scala

This file was deleted.

13 changes: 0 additions & 13 deletions tests/neg/symbolic-packages.scala

This file was deleted.

20 changes: 0 additions & 20 deletions tests/neg/warn-value-discard.check

This file was deleted.

15 changes: 15 additions & 0 deletions tests/warn/14034b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//> using options -deprecation

@deprecated trait Exp
@deprecated val exp = 1

def test1 = exp // warn
def test2(a: Exp) = () // warn

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 // warn
type Quuz[A <: Exp] = Int // warn
4 changes: 2 additions & 2 deletions tests/neg/15981.check → tests/warn/15981.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- [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/warn/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
|
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/15981.scala → tests/warn/15981.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//> 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
}
}
12 changes: 6 additions & 6 deletions tests/neg/17284.check → tests/warn/17284.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- [E187] Potential Issue Error: tests/neg/17284.scala:4:6 -------------------------------------------------------------
4 | 451.synchronized {} // error
-- [E187] Potential Issue Warning: tests/warn/17284.scala:4:6 ----------------------------------------------------------
4 | 451.synchronized {} // warn
| ^^^^^^^^^^^^^^^^
| Suspicious synchronized call on boxed class
|---------------------------------------------------------------------------------------------------------------------
Expand All @@ -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/warn/17284.scala:8:4 ----------------------------------------------------------
8 | x.synchronized {} // warn
| ^^^^^^^^^^^^^^
| Suspicious synchronized call on boxed class
|---------------------------------------------------------------------------------------------------------------------
Expand All @@ -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/warn/17284.scala:11:7 ---------------------------------------------------------
11 | true.synchronized {} // warn
| ^^^^^^^^^^^^^^^^^
| Suspicious synchronized call on boxed class
|--------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions tests/warn/17284.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//> using options -explain

def test =
451.synchronized {} // warn

def test2 =
val x: Integer = 451
x.synchronized {} // warn

def test3 =
true.synchronized {} // warn

def test4 =
true.hashCode() // success
4 changes: 2 additions & 2 deletions tests/neg-deep-subtype/1828.scala → tests/warn/1828.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//> using options -Xfatal-warnings


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)
}

Expand Down
8 changes: 8 additions & 0 deletions tests/warn/18493.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- [E030] Match case Unreachable Warning: tests/warn/18493.scala:6:9 ---------------------------------------------------
6 | case "abc" => // warn
| ^^^^^
| Unreachable case
-- [E030] Match case Unreachable Warning: tests/warn/18493.scala:12:9 --------------------------------------------------
12 | case "abc" => // warn
| ^^^^^
| Unreachable case
6 changes: 3 additions & 3 deletions tests/neg/18493.scala → tests/warn/18493.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//> using options -Werror

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
}
}
11 changes: 11 additions & 0 deletions tests/warn/3324b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


class C[T] {
val x: Any = ???
if (x.isInstanceOf[List[String]]) // warn: unchecked
if (x.isInstanceOf[T]) // warn: unchecked
x match {
case x: List[String] => // warn: unchecked
case x: T => // warn: unchecked
}
}
11 changes: 11 additions & 0 deletions tests/warn/3324f.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


trait C[T]
class D[T]

class Test {
def foo[T](x: C[T]) = x match {
case _: D[T] => // warn
case _: C[Int] => // warn
}
}
Loading