Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Jan 31, 2024
1 parent 749fc3c commit 35b0509
Show file tree
Hide file tree
Showing 45 changed files with 109 additions and 149 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ abstract class Reporter extends interfaces.ReporterResult {
def incomplete(dia: Diagnostic)(using Context): Unit =
incompleteHandler(dia, ctx)

def finalizeReporting()(using Context) =
def finalizeReporting()(using Context) =
if (hasWarnings && ctx.settings.XfatalWarnings.value)
report(new Error("No warnings can be incurred under -Werror.", NoSourcePosition))
report(new Error("No warnings can be incurred under -Werror (or -Xfatal-warnings)", NoSourcePosition))

/** Summary of warnings and errors */
def summary: String = {
Expand Down
4 changes: 2 additions & 2 deletions compiler/test-resources/repl/rewrite-messages
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scala> import scala.util._
1 | import scala.util._
| ^
| `_` is no longer supported for a wildcard import; use `*` instead
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
1 warning found
1 error found
scala> extension (x: Int) def foo(y: Int) = x + y
Expand All @@ -15,6 +15,6 @@ scala> 2 foo 4
| ^^^
|Alphanumeric method foo is not declared infix; it should not be used as infix operator.
|Instead, use method syntax .foo(...) or backticked identifier `foo`.
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
1 warning found
1 error found
3 changes: 1 addition & 2 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ class CompilationTests {
// initialization tests
@Test def checkInitGlobal: Unit = {
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
compileFilesInDir("tests/init-global/warn", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkWarnings()
compileFilesInDir("tests/init-global/pos", options, FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile()
compileFilesInDir("tests/init-global/pos", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile()
}

// initialization tests
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/sourcepath2/hi/A.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
| class Hello is in the wrong directory.
| It was declared to be in package <empty>
| But it is found in directory hi
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg-macros/i9570.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
15 | case '{HCons(_,$t)} => // warn (in .check file)
| ^
| Use of `_` for lambda in quoted pattern. Use explicit lambda instead or use `$_` to match any term.
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
4 changes: 2 additions & 2 deletions tests/neg-macros/i9570.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ object Macros {

inline def size(inline expr: HList ): Int = {
${sizeImpl('expr,0)}
}
}

}
}

// nopos-error No warnings can be incurred under -Werror.
// nopos-error No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg-macros/macro-deprecation.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
5 |inline def f = ${ impl } // warn (in .check file)
| ^^^^
| method impl is deprecated
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg-macros/macro-deprecation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import scala.quoted.*
inline def f = ${ impl } // warn (in .check file)
@deprecated def impl(using Quotes) = '{1}

// nopos-error No warnings can be incurred under -Werror.
// nopos-error No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg-scalajs/enumeration-warnings.check
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
| ^^^^^^^^^^^^
| Passing null as name to a constructor of scala.Enumeration.Val requires reflection at run-time.
| The resulting program is unlikely to function properly.
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg-scalajs/enumeration-warnings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ class ExtendsValWithNullName extends Enumeration {
protected class Val2 extends Val(1, null) // warn
}

// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/adhoc-extension/B.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ object O {
val a = new A {} // warn
object E extends A // warn
}
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/capt-wf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def test(c: Cap, other: String): Unit =
val y3: String^{ev} = ??? // error cs is empty

()
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/classtag-typetest/3_1-migration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import scala.reflect.ClassTag
def f3_1m[T: ClassTag](x: Any): Unit =
x match
case _: T => // warn
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/classtag-typetest/3_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import scala.reflect.ClassTag
def f3_1[T: ClassTag](x: Any): Unit =
x match
case _: T => // warn
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i12188/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def foo(x: P): Unit =
x match // warn
case _: PC1 =>

// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i13946/BadPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import language.future
class BadPrinter extends Printer: // warn
override def print(s: String): Unit = println("Bad!!!")
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i14386.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def braced() =
log(level, msg) // warn
}
end"""
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
5 changes: 3 additions & 2 deletions tests/neg/i15474b.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Error: tests/neg/i15474b.scala:7:40 ---------------------------------------------------------------------------------
7 | def apply(from: String): Int = from.toInt // error: infinite loop in function body
-- Warning: tests/neg/i15474b.scala:7:40 -------------------------------------------------------------------------------
7 | def apply(from: String): Int = from.toInt // warn: infinite loop in function body
| ^^^^^^^^^^
| Infinite loop in function body
| Test1.c.apply(from).toInt
No warnings can be incurred under -Werror (or -Xfatal-warnings)
4 changes: 2 additions & 2 deletions tests/neg/i15474b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import scala.language.implicitConversions

object Test1:
given c: Conversion[ String, Int ] with
def apply(from: String): Int = from.toInt // error: infinite loop in function body

def apply(from: String): Int = from.toInt // warn: infinite loop in function body
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i16876/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ object Foo {
private def myMethodFailing(a: Int, b: Int, c: Int) = a + 0 // warn // warn
myMethodFailing(1, 2, 3)
}
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i17612b.check
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
41 | class UnderDerived(x: Int, y: Int, z: Int) extends Derived(x, 1, y, z) // warn // warn // warn
| ^
| value z in class UnderDerived shadows field z inherited from trait Base
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i17612b/i17612b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ object i17612b:

def main(args: Array[String]) =
val derived = new Derived(1, 1, 1, 1)
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i17613b.check
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
42 | class InnerCl[ImClassR] // warn
| ^^^^^^^^
| Type parameter ImClassR for class InnerCl shadows an explicitly renamed type : ImClassR
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i4986d.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ trait Bar[A]
type Barable[A] = {
def bar(implicit ev: Bar[A]): Any // ok
}
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
5 changes: 3 additions & 2 deletions tests/neg/i6716.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Error: tests/neg/i6716.scala:12:39 ----------------------------------------------------------------------------------
12 | given Monad[Bar] = summon[Monad[Foo]] // error
-- Warning: tests/neg/i6716.scala:12:39 --------------------------------------------------------------------------------
12 | given Monad[Bar] = summon[Monad[Foo]] // warn
| ^
| Result of implicit search for Monad[Foo] will change.
| Current result Bar.given_Monad_Bar will be no longer eligible
Expand All @@ -13,3 +13,4 @@
| - rearrange definitions so that Bar.given_Monad_Bar comes earlier,
| - use an explicit argument.
| This will be an error in Scala 3.5 and later.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
5 changes: 3 additions & 2 deletions tests/neg/i6716.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ object Foo {

opaque type Bar = Foo
object Bar {
given Monad[Bar] = summon[Monad[Foo]] // error
given Monad[Bar] = summon[Monad[Foo]] // warn
}

object Test extends App {
println(summon[Monad[Foo]].id)
println(summon[Monad[Bar]].id)
}
}
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
7 changes: 4 additions & 3 deletions tests/neg/i7294-a.check
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-- [E007] Type Mismatch Error: tests/neg/i7294-a.scala:10:20 -----------------------------------------------------------
10 | case x: T => x.g(10) // error // error
10 | case x: T => x.g(10) // error
| ^^^^^^^
| Found: Any
| Required: T
|
| where: T is a type in given instance f with bounds <: foo.Foo
|
| longer explanation available when compiling with `-explain`
-- Error: tests/neg/i7294-a.scala:10:12 --------------------------------------------------------------------------------
10 | case x: T => x.g(10) // error // error
-- Warning: tests/neg/i7294-a.scala:10:12 ------------------------------------------------------------------------------
10 | case x: T => x.g(10) // error
| ^
| Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change.
| Current result foo.Test.f will be no longer eligible
Expand All @@ -24,3 +24,4 @@
| This will be an error in Scala 3.5 and later.
|
| where: T is a type in given instance f with bounds <: foo.Foo
No warnings can be incurred under -Werror (or -Xfatal-warnings)
3 changes: 2 additions & 1 deletion tests/neg/i7294-a.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ trait Foo { def g(x: Int): Any }
object Test:

inline given f[T <: Foo]: T = ??? match {
case x: T => x.g(10) // error // error
case x: T => x.g(10) // error
}

@main def Test = f
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
3 changes: 2 additions & 1 deletion tests/neg/i7294-b.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ package foo
trait Foo { def g(x: Any): Any }

inline given f[T <: Foo]: T = ??? match {
case x: T => x.g(10) // error // error
case x: T => x.g(10) // error
}

@main def Test = f
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i8681.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ val b = (A(1): A | B) match {
case B(_) => "OK"
case C(_) => "NOT OK" // error
}
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i8711.check
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
14 | case x: C => x // error
| ^
| this case is unreachable since type A | B and class C are unrelated
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i8711.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ object Test {
}
}

// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i9408b.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
8 | val length: Int = "abc" // warn
| ^^^^^
|The conversion (test.conversions.Conv.implicitLength : String => Int) will not be applied implicitly here in Scala 3 because only implicit methods and instances of Conversion class will continue to work as implicit views.
No warnings can be incurred under -Werror.
No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/i9408b/Test_2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ object Test {
val length: Int = "abc" // warn
}

// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/impl-conv/B.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ object B {
val x: Int = "" // ok
val y: String = 1 // warn: feature
}
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
2 changes: 1 addition & 1 deletion tests/neg/indentLeft.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//> using options -Xfatal-warnings
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)

object Test {

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/indentRight.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ object Test {

println("!") // error: expected a toplevel definition
}
// nopos-error: No warnings can be incurred under -Werror.
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
Loading

0 comments on commit 35b0509

Please sign in to comment.