-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
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
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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 | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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 |
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 | ||
} | ||
} |
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 |