Skip to content

Commit

Permalink
More tests moved to warn
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Nov 3, 2023
1 parent a9a67d5 commit 17b6e5a
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 48 deletions.
9 changes: 0 additions & 9 deletions tests/neg/rewrite-messages.scala

This file was deleted.

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

This file was deleted.

3 changes: 1 addition & 2 deletions tests/neg/15981.scala → tests/warn/15981.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//> using options -Werror

val _ = locally{
sealed abstract class PosInt(val value: Int) {
override def equals(any: Any): Boolean = any.isInstanceOf[PosInt] // warn
}
}
// nopos-error: No warnings can be incurred under -Werror.
5 changes: 2 additions & 3 deletions tests/neg/17284.scala → tests/warn/17284.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror -explain
//> using options -explain

def test =
451.synchronized {} // warn
Expand All @@ -11,5 +11,4 @@ def test3 =
true.synchronized {} // warn

def test4 =
true.hashCode() // success
// nopos-error: No warnings can be incurred under -Werror.
true.hashCode() // success
5 changes: 2 additions & 3 deletions tests/neg/18493.scala → tests/warn/18493.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror

object PartialFunctionNoWarning {
// nice warning
"abc" match {
Expand All @@ -11,5 +11,4 @@ object PartialFunctionNoWarning {
case "abc" =>
case "abc" => // warn
}
}
// nopos-error: No warnings can be incurred under -Werror.
}
5 changes: 2 additions & 3 deletions tests/neg/i15503i.scala → tests/warn/i15503i.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -Wunused:all
//> using options -Wunused:all

import collection.mutable.{Map => MutMap} // warn
import collection.mutable.Set // warn
Expand Down Expand Up @@ -312,5 +312,4 @@ package foo.test.i17117:

val test = t1.test
}
}
// nopos-error: No warnings can be incurred under -Werror.
}
5 changes: 2 additions & 3 deletions tests/neg/i15893.scala → tests/warn/i15893.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings


sealed trait NatT
case class Zero() extends NatT
Expand Down Expand Up @@ -60,5 +60,4 @@ inline def transparentInlineFoo(inline n: NatT): NatT = inline transparentInline
println(transparentInlineFoo(Succ(Succ(Succ(Zero()))))) // prints Zero(), as expected
println(dependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // runtime error; unexpected
println(inlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected
println(transparentInlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected
// nopos-error: No warnings can be incurred under -Werror.
println(transparentInlineDependentlyTypedMod2(Succ(Succ(Succ(Zero()))))) // prints Succ(Zero()), as expected
5 changes: 2 additions & 3 deletions tests/neg/i17266.scala → tests/warn/i17266.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror -explain
//> using options -explain

def test1 =
synchronized { // warn
Expand Down Expand Up @@ -141,5 +141,4 @@ def test26 =
hashCode() // warn

def test27 =
1.hashCode()// not an error (should be? probably not)
// nopos-error: No warnings can be incurred under -Werror.
1.hashCode()// not an error (should be? probably not)
5 changes: 2 additions & 3 deletions tests/neg/i18722.scala → tests/warn/i18722.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//> using options -Werror -explain
//> using options -explain

def f1: Unit = null // warn
def f2: Unit = 1 // warn
def f3: Unit = "a" // warn
val i: Int = 1
def f4: Unit = i // warn
val u: Unit = ()
def f5: Unit = u
// nopos-error: No warnings can be incurred under -Werror.
def f5: Unit = u
5 changes: 2 additions & 3 deletions tests/neg/i4812.scala → tests/warn/i4812.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror

object Test:
var prev: Any = _

Expand Down Expand Up @@ -116,5 +116,4 @@ object Test:

def main(args: Array[String]): Unit =
test(1)
val x: String = test("") // was: ClassCastException: java.lang.Integer cannot be cast to java.lang.String
// nopos-error: No warnings can be incurred under -Werror.
val x: String = test("") // was: ClassCastException: java.lang.Integer cannot be cast to java.lang.String
5 changes: 2 additions & 3 deletions tests/neg/i5077.scala → tests/warn/i5077.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -Wimplausible-patterns
//> using options -Wimplausible-patterns
trait Is[A]
case object IsInt extends Is[Int]
case object IsString extends Is[String]
Expand Down Expand Up @@ -30,5 +30,4 @@ def Test = {
case C(IsString, s) => println(s"A String with length ${s.length}")
case _ => println("No match")
}
}
// nopos-error: No warnings can be incurred under -Werror.
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Werror

object Test {
// refutable extractor
object Positive { def unapply(i: Int): Option[Int] = Some(i).filter(_ > 0) }
Expand All @@ -14,5 +14,4 @@ object Test {
val ys: List[Option[?]] = ???
for none @ None <- ys do () // warn: pattern type does not match
val 1 = 2 // warn: pattern type does not match
}
// nopos-error: No warnings can be incurred under -Werror.
}
8 changes: 8 additions & 0 deletions tests/warn/rewrite-messages.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//> using options -source:future-migration -deprecation

import scala.util._ // warn

object Test {
extension (x: Int) def foo(y: Int) = x + y
2 foo 4 // warn
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Wvalue-discard -Werror
//> using options -Wvalue-discard

import scala.util.{Either, Right, Left}
import scala.collection.mutable
Expand Down Expand Up @@ -63,5 +63,4 @@ class ValueDiscardTest:
// - receiver is a local variable
// --> No warning
val s: mutable.Set[String] = mutable.Set.empty[String]
s += ""
// nopos-error: No warnings can be incurred under -Werror.
s += ""
6 changes: 6 additions & 0 deletions tests/warn/with-type-operator-future-migration.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


import scala.language.`future-migration`

def foo: Int with String = ??? // warn

0 comments on commit 17b6e5a

Please sign in to comment.