Skip to content

Commit

Permalink
Second batch of neg -> warn test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Jan 11, 2024
1 parent 36831b8 commit f8bb34d
Show file tree
Hide file tree
Showing 81 changed files with 648 additions and 381 deletions.
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.

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.

7 changes: 0 additions & 7 deletions tests/neg/private-this-3.4.scala

This file was deleted.

7 changes: 0 additions & 7 deletions tests/neg/private-this-future-migration.scala

This file was deleted.

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

This file was deleted.

5 changes: 0 additions & 5 deletions tests/neg/refinements-this.scala

This file was deleted.

12 changes: 6 additions & 6 deletions tests/neg/refutable-pattern-binding-messages.check
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
| 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: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: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: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)
|
Expand Down
8 changes: 4 additions & 4 deletions tests/neg/refutable-pattern-binding-messages.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//> using options -Werror

object Test {
// refutable extractor
object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) }
val Positive(p) = 5 // error: refutable extractor
val Positive(p) = 5 // warn: refutable extractor
for Positive(i) <- List(1, 2, 3) do () // error: refutable extractor

// more specialized
val xs: List[AnyRef] = ???
val i :: is = List(1, 2, 3) // error: pattern type more specialized
val i :: is = List(1, 2, 3) // warn: pattern type more specialized
for ((x: String) <- xs) do () // error: 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
val 1 = 2 // warn: pattern type does not match
}
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.

5 changes: 0 additions & 5 deletions tests/neg/with-type-operator-future-migration.scala

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


class Test {
def remove[S](a: S | Int, f: Int => S):S = a match {
case a: S => a // warn
case a: Int => f(a)
}

val t: Int | String = 5
val t1 = remove[String](t, _.toString)
}
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
Loading

0 comments on commit f8bb34d

Please sign in to comment.