Skip to content

Commit

Permalink
Move warn tests from tests/neg to tests/warn: Batch 2 (#19243)
Browse files Browse the repository at this point in the history
The second batch of tests moved from tests/neg to tests/warn.
PR 3/5 (merge consecutively, per [Nicolas'
suggestion](#18829 (review))

Split up version of #18829
  • Loading branch information
nicolasstucki authored Jan 19, 2024
2 parents 36ee954 + 69d1de3 commit cacf2b6
Show file tree
Hide file tree
Showing 83 changed files with 428 additions and 436 deletions.
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.

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
Loading

0 comments on commit cacf2b6

Please sign in to comment.