diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 120b7373f7cc..798af9bdd6b5 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -225,6 +225,7 @@ class CompilationTests { implicit val testGroup: TestGroup = TestGroup("checkInit") val options = defaultOptions.and("-Ysafe-init", "-Xfatal-warnings") compileFilesInDir("tests/init/neg", options).checkExpectedErrors() + compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings() compileFilesInDir("tests/init/pos", options).checkCompile() compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile() // The regression test for i12128 has some atypical classpath requirements. diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index e93a0435987b..174fbb60ef34 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -776,7 +776,7 @@ trait ParallelTesting extends RunnerOrchestration { self => end maybeFailureMessage def getWarnMapAndExpectedCount(files: Seq[JFile]): (HashMap[String, Integer], Int) = - val comment = raw"//( *)warn".r + val comment = raw"//( *)(nopos-)?warn".r val map = new HashMap[String, Integer]() var count = 0 def bump(key: String): Unit = @@ -787,8 +787,11 @@ trait ParallelTesting extends RunnerOrchestration { self => files.filter(isSourceFile).foreach { file => Using(Source.fromFile(file, StandardCharsets.UTF_8.name)) { source => source.getLines.zipWithIndex.foreach { case (line, lineNbr) => - comment.findAllMatchIn(line).foreach { _ => - bump(s"${file.getPath}:${lineNbr+1}") + comment.findAllMatchIn(line).foreach { m => + m.group(2) match + case "nopos-" => + bump("nopos") + case _ => bump(s"${file.getPath}:${lineNbr+1}") } } }.get @@ -809,7 +812,7 @@ trait ParallelTesting extends RunnerOrchestration { self => val key = s"${relativize(srcpos.source.file.toString())}:${srcpos.line + 1}" if !seenAt(key) then unexpected += key else - unpositioned += relativize(srcpos.source.file.toString()) + if(!seenAt("nopos")) unpositioned += relativize(srcpos.source.file.toString()) reporterWarnings.foreach(sawDiagnostic) diff --git a/tests/init/neg/early-promote2.scala b/tests/init/neg/early-promote2.scala deleted file mode 100644 index 514aed36a8ed..000000000000 --- a/tests/init/neg/early-promote2.scala +++ /dev/null @@ -1,6 +0,0 @@ -class M { - println(this) // error - foo() - private val a = 5 // error - def foo() = a -} diff --git a/tests/init/neg/simple1.scala b/tests/init/neg/simple1.scala deleted file mode 100644 index 93fba24008b9..000000000000 --- a/tests/init/neg/simple1.scala +++ /dev/null @@ -1,4 +0,0 @@ -class Foo { - val len = name.size - val name: String = "Jack" // error -} \ No newline at end of file diff --git a/tests/init/neg/soundness4.scala b/tests/init/neg/soundness4.scala deleted file mode 100644 index 308856b5e870..000000000000 --- a/tests/init/neg/soundness4.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Foo { - val a : Foo = this.a.a // error -} \ No newline at end of file diff --git a/tests/init/neg/AbstractFile.scala b/tests/init/warn/AbstractFile.scala similarity index 64% rename from tests/init/neg/AbstractFile.scala rename to tests/init/warn/AbstractFile.scala index f4f38982608a..bb8abc6e8322 100644 --- a/tests/init/neg/AbstractFile.scala +++ b/tests/init/warn/AbstractFile.scala @@ -4,6 +4,6 @@ abstract class AbstractFile { } class RemoteFile(url: String) extends AbstractFile { - val localFile: String = s"${url.##}.tmp" // error: usage of `localFile` before it's initialized + val localFile: String = s"${url.##}.tmp" // warn: usage of `localFile` before it's initialized def name: String = localFile } diff --git a/tests/init/neg/alias.scala b/tests/init/warn/alias.scala similarity index 63% rename from tests/init/neg/alias.scala rename to tests/init/warn/alias.scala index 79367b36d0c5..8e9cb56b75c0 100644 --- a/tests/init/neg/alias.scala +++ b/tests/init/warn/alias.scala @@ -1,5 +1,5 @@ class Foo { val self = this val x = self.n - val n = 10 // error + val n = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/apply.scala b/tests/init/warn/apply.scala similarity index 85% rename from tests/init/neg/apply.scala rename to tests/init/warn/apply.scala index 2847115cc73c..fffa4c59968f 100644 --- a/tests/init/neg/apply.scala +++ b/tests/init/warn/apply.scala @@ -6,7 +6,7 @@ object A: class B: val a = A(this) - val a2 = A.foo(this) // error + val a2 = A.foo(this) // warn val a3 = A.bar(this) // test receiver is ThisRef @@ -20,7 +20,7 @@ object O: class B: val a = A(this) - val a2 = A.foo(this) // error + val a2 = A.foo(this) // warn val a3 = A.bar(this) val b = new B @@ -38,7 +38,7 @@ class M(n: N): class B: val a = A(this) - val a2 = A.foo(this) // error + val a2 = A.foo(this) // warn val a3 = A.bar(this) end M diff --git a/tests/init/neg/apply2.scala b/tests/init/warn/apply2.scala old mode 100755 new mode 100644 similarity index 75% rename from tests/init/neg/apply2.scala rename to tests/init/warn/apply2.scala index ea312ac6e8c7..efb083cfc863 --- a/tests/init/neg/apply2.scala +++ b/tests/init/warn/apply2.scala @@ -3,7 +3,7 @@ class O: println(n) class B: - val a = A(this) // error + val a = A(this) // warn val b = new B val n = 10 diff --git a/tests/init/neg/as-instance-of-cold-field-access.scala b/tests/init/warn/as-instance-of-cold-field-access.scala similarity index 78% rename from tests/init/neg/as-instance-of-cold-field-access.scala rename to tests/init/warn/as-instance-of-cold-field-access.scala index c8de99e96d0e..caef6f42f623 100644 --- a/tests/init/neg/as-instance-of-cold-field-access.scala +++ b/tests/init/warn/as-instance-of-cold-field-access.scala @@ -1,7 +1,7 @@ final class MyAsInstanceOfClass(o: MyAsInstanceOfClass) { val other: MyAsInstanceOfClass = { if (o.asInstanceOf[MyAsInstanceOfClass].oRef ne null) o - else new MyAsInstanceOfClass(this) // error + else new MyAsInstanceOfClass(this) // warn } val oRef = o } diff --git a/tests/init/neg/by-name-error.scala b/tests/init/warn/by-name-error.scala similarity index 79% rename from tests/init/neg/by-name-error.scala rename to tests/init/warn/by-name-error.scala index 960bbe9bf7e9..8d3a690c7cfd 100644 --- a/tests/init/neg/by-name-error.scala +++ b/tests/init/warn/by-name-error.scala @@ -8,6 +8,6 @@ object Foo { } class A { - val foo = implicitly[Foo] // error + val foo = implicitly[Foo] // warn assert(foo eq foo.next) } \ No newline at end of file diff --git a/tests/init/neg/closureLeak.scala b/tests/init/warn/closureLeak.scala similarity index 83% rename from tests/init/neg/closureLeak.scala rename to tests/init/warn/closureLeak.scala index ae7db5124028..3e4e1f88102b 100644 --- a/tests/init/neg/closureLeak.scala +++ b/tests/init/warn/closureLeak.scala @@ -8,6 +8,6 @@ class Outer { } val l: List[A] = List(new A(5), new A(10)) - l.foreach(a => a.addX(this)) // error + l.foreach(a => a.addX(this)) // warn val p = 10 } diff --git a/tests/init/neg/cold-insert-hot-array.scala b/tests/init/warn/cold-insert-hot-array.scala similarity index 84% rename from tests/init/neg/cold-insert-hot-array.scala rename to tests/init/warn/cold-insert-hot-array.scala index a11d92b2a265..a6c4b4aaebfd 100644 --- a/tests/init/neg/cold-insert-hot-array.scala +++ b/tests/init/warn/cold-insert-hot-array.scala @@ -3,7 +3,7 @@ object A: class B { var a = new Array[B](2) - A.foo(this, a) // error + A.foo(this, a) // warn println(a(0).i) val i = 99 } diff --git a/tests/init/neg/cycle-structure.scala b/tests/init/warn/cycle-structure.scala similarity index 64% rename from tests/init/neg/cycle-structure.scala rename to tests/init/warn/cycle-structure.scala index 1a02a31188b1..f3eb7560f414 100644 --- a/tests/init/neg/cycle-structure.scala +++ b/tests/init/warn/cycle-structure.scala @@ -1,11 +1,11 @@ case class A(b: B) { val x1 = b.x - val x = B(this) // error + val x = B(this) // warn val y = x.a } case class B(a: A) { val x1 = a.x - val x = A(this) // error + val x = A(this) // warn val h = x.b } diff --git a/tests/init/neg/cycle.scala b/tests/init/warn/cycle.scala similarity index 59% rename from tests/init/neg/cycle.scala rename to tests/init/warn/cycle.scala index 7d871795f0a2..f3733df03da4 100644 --- a/tests/init/neg/cycle.scala +++ b/tests/init/warn/cycle.scala @@ -1,11 +1,11 @@ class A(x: B) { println(x.b) - val a = new B(this) // error + val a = new B(this) // warn val d = a.b } class B(x: A) { println(x.a) - val b = new A(this) // error + val b = new A(this) // warn val d = b.a } \ No newline at end of file diff --git a/tests/init/neg/default-this.scala b/tests/init/warn/default-this.scala similarity index 89% rename from tests/init/neg/default-this.scala rename to tests/init/warn/default-this.scala index 1b0173fc134f..26b669bcbd40 100644 --- a/tests/init/neg/default-this.scala +++ b/tests/init/warn/default-this.scala @@ -6,7 +6,7 @@ class A { class B extends A { def updateThenCompare(c: Int): Boolean = { x = c - compare() // error + compare() // warn } val result = updateThenCompare(5) } diff --git a/tests/init/neg/early-promote.scala b/tests/init/warn/early-promote.scala similarity index 84% rename from tests/init/neg/early-promote.scala rename to tests/init/warn/early-promote.scala index fd226df347fb..1cd608d3f63b 100644 --- a/tests/init/neg/early-promote.scala +++ b/tests/init/warn/early-promote.scala @@ -24,7 +24,7 @@ class A { // checking A def c = new C } val b = new B() - println(b) // error: the checker simply issue warnings for objects that contain inner classes + println(b) // warn: the checker simply issue warnings for objects that contain inner classes val af = 42 } diff --git a/tests/init/warn/early-promote2.scala b/tests/init/warn/early-promote2.scala new file mode 100644 index 000000000000..8326aa851e21 --- /dev/null +++ b/tests/init/warn/early-promote2.scala @@ -0,0 +1,6 @@ +class M { + println(this) // warn + foo() + private val a = 5 // warn + def foo() = a +} diff --git a/tests/init/neg/early-promote3.scala b/tests/init/warn/early-promote3.scala similarity index 77% rename from tests/init/neg/early-promote3.scala rename to tests/init/warn/early-promote3.scala index ecb5bbedca69..a81b261d78ba 100644 --- a/tests/init/neg/early-promote3.scala +++ b/tests/init/warn/early-promote3.scala @@ -6,6 +6,6 @@ abstract class A { } class M extends A { - def bar() = promote(this) // error + def bar() = promote(this) // warn def promote(m: M) = m.foo() } diff --git a/tests/init/neg/early-promote4.scala b/tests/init/warn/early-promote4.scala similarity index 87% rename from tests/init/neg/early-promote4.scala rename to tests/init/warn/early-promote4.scala index 487a75c5516f..9d215b308200 100644 --- a/tests/init/neg/early-promote4.scala +++ b/tests/init/warn/early-promote4.scala @@ -16,5 +16,5 @@ class Outer { class Dummy { val m: Int = n + 4 - val n: Int = 10 // error + val n: Int = 10 // warn } diff --git a/tests/init/neg/early-promote5.scala b/tests/init/warn/early-promote5.scala similarity index 80% rename from tests/init/neg/early-promote5.scala rename to tests/init/warn/early-promote5.scala index 3f850b623ea3..bbcc63527fdf 100644 --- a/tests/init/neg/early-promote5.scala +++ b/tests/init/warn/early-promote5.scala @@ -14,11 +14,11 @@ class Outer { class Container { val o = new Outer - val m = new o.M(this) // error + val m = new o.M(this) // warn val s = "hello" } class Dummy { val m: Int = n + 4 - val n: Int = 10 // error + val n: Int = 10 // warn } diff --git a/tests/init/neg/escape1.scala b/tests/init/warn/escape1.scala similarity index 71% rename from tests/init/neg/escape1.scala rename to tests/init/warn/escape1.scala index 588f0933cfc3..ff0cb4ea3816 100644 --- a/tests/init/neg/escape1.scala +++ b/tests/init/warn/escape1.scala @@ -1,5 +1,5 @@ class Foo { - val a = Foo.bar(this) // error + val a = Foo.bar(this) // warn val b = "hello" } diff --git a/tests/init/neg/features-high-order.scala b/tests/init/warn/features-high-order.scala similarity index 81% rename from tests/init/neg/features-high-order.scala rename to tests/init/warn/features-high-order.scala index 60c15545cc14..6f758aeb6785 100644 --- a/tests/init/neg/features-high-order.scala +++ b/tests/init/warn/features-high-order.scala @@ -4,6 +4,6 @@ abstract class Parent { } class Child extends Parent { val a = f() - val b = "hello" // error + val b = "hello" // warn def message: String = b } diff --git a/tests/init/neg/features-linearization.scala b/tests/init/warn/features-linearization.scala similarity index 82% rename from tests/init/neg/features-linearization.scala rename to tests/init/warn/features-linearization.scala index 77d6a231d79a..d3c7b7b0db47 100644 --- a/tests/init/neg/features-linearization.scala +++ b/tests/init/warn/features-linearization.scala @@ -1,5 +1,5 @@ trait TA { - val x = "world" // error + val x = "world" // warn } trait TB { diff --git a/tests/init/neg/features-trees.scala b/tests/init/warn/features-trees.scala similarity index 76% rename from tests/init/neg/features-trees.scala rename to tests/init/warn/features-trees.scala index 867e6636bb12..32026785b3e5 100644 --- a/tests/init/neg/features-trees.scala +++ b/tests/init/warn/features-trees.scala @@ -2,5 +2,5 @@ class Trees { class ValDef { counter += 1 } class EmptyValDef extends ValDef val theEmptyValDef = new EmptyValDef - private var counter = 0 // error + private var counter = 0 // warn } diff --git a/tests/init/neg/final-fields.scala b/tests/init/warn/final-fields.scala similarity index 72% rename from tests/init/neg/final-fields.scala rename to tests/init/warn/final-fields.scala index 7154673058b7..878a1c44c49f 100644 --- a/tests/init/neg/final-fields.scala +++ b/tests/init/warn/final-fields.scala @@ -29,10 +29,10 @@ class Test1 extends U { } class Test extends T { - override final val f1 = /*super.f1*/ 1 + f2 // error - override final val f2 = 2 // error - override final val f3 = {println(3); 3} // error - override val f4 = f3 + 1 // error + override final val f1 = /*super.f1*/ 1 + f2 // warn + override final val f2 = 2 // warn + override final val f3 = {println(3); 3} // warn + override val f4 = f3 + 1 // warn def g: 3 = { println("g"); 3 } final val x = g + 1 diff --git a/tests/init/neg/flow2.scala b/tests/init/warn/flow2.scala similarity index 73% rename from tests/init/neg/flow2.scala rename to tests/init/warn/flow2.scala index a0c5f89601ee..3bb4fa110e50 100644 --- a/tests/init/neg/flow2.scala +++ b/tests/init/warn/flow2.scala @@ -1,6 +1,6 @@ class Foo { val len = list.size - val list = List(4, 6) // error + val list = List(4, 6) // warn lazy val len2 = list2.size // ok val list2 = List(4, 6) diff --git a/tests/init/neg/function-loop.scala b/tests/init/warn/function-loop.scala similarity index 78% rename from tests/init/neg/function-loop.scala rename to tests/init/warn/function-loop.scala index 12048860c3a6..981e8f8215c5 100644 --- a/tests/init/neg/function-loop.scala +++ b/tests/init/warn/function-loop.scala @@ -2,5 +2,5 @@ class Foo { val f: Int => Foo = (x: Int) => if x > 0 then f(x) else this f(10).n - val n = 10 // error + val n = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/function1.scala b/tests/init/warn/function1.scala similarity index 60% rename from tests/init/neg/function1.scala rename to tests/init/warn/function1.scala index 15427f3de750..29a139b39bd2 100644 --- a/tests/init/neg/function1.scala +++ b/tests/init/warn/function1.scala @@ -4,9 +4,9 @@ class Foo { val fun2: Int => Int = n => 1 + n + list.size fun2(5) - List(5, 9).map(n => 2 + n + list.size) // error + List(5, 9).map(n => 2 + n + list.size) // warn - final val list = List(1, 2, 3) // error + final val list = List(1, 2, 3) // warn List(5, 9).map(n => 3 + n + list.size) } \ No newline at end of file diff --git a/tests/init/neg/function10.scala b/tests/init/warn/function10.scala similarity index 53% rename from tests/init/neg/function10.scala rename to tests/init/warn/function10.scala index 3d8a72aaa1ea..22260bb5d622 100644 --- a/tests/init/neg/function10.scala +++ b/tests/init/warn/function10.scala @@ -1,5 +1,5 @@ class Base { self => - (0 to 10).foreach { i => // error + (0 to 10).foreach { i => // warn println(a) } diff --git a/tests/init/neg/function11.scala b/tests/init/warn/function11.scala similarity index 89% rename from tests/init/neg/function11.scala rename to tests/init/warn/function11.scala index 278192d003aa..a50f7937b562 100644 --- a/tests/init/neg/function11.scala +++ b/tests/init/warn/function11.scala @@ -1,7 +1,7 @@ final class Capture { private var m: Boolean = false - (0 to 10).foreach { i => // error + (0 to 10).foreach { i => // warn f() } diff --git a/tests/init/neg/function2.scala b/tests/init/warn/function2.scala similarity index 70% rename from tests/init/neg/function2.scala rename to tests/init/warn/function2.scala index 0a0f44e2744e..045eb8f4289e 100644 --- a/tests/init/neg/function2.scala +++ b/tests/init/warn/function2.scala @@ -2,5 +2,5 @@ final class Foo { def fun: Int => Int = n => n + x.size fun(5) - val x = "hello" // error + val x = "hello" // warn } \ No newline at end of file diff --git a/tests/init/neg/hybrid1.scala b/tests/init/warn/hybrid1.scala similarity index 87% rename from tests/init/neg/hybrid1.scala rename to tests/init/warn/hybrid1.scala index 94c7a43bfbcd..f1a4665954c9 100644 --- a/tests/init/neg/hybrid1.scala +++ b/tests/init/warn/hybrid1.scala @@ -17,5 +17,5 @@ class Y { new C - val n = 10 // error + val n = 10 // warn } diff --git a/tests/init/neg/hybrid2.scala b/tests/init/warn/hybrid2.scala similarity index 84% rename from tests/init/neg/hybrid2.scala rename to tests/init/warn/hybrid2.scala index a9f8246fd58d..6d901d810a64 100644 --- a/tests/init/neg/hybrid2.scala +++ b/tests/init/warn/hybrid2.scala @@ -15,5 +15,5 @@ class Y { val x = new X x.b.g - val n = 10 // error + val n = 10 // warn } diff --git a/tests/init/neg/hybrid4.scala b/tests/init/warn/hybrid4.scala similarity index 75% rename from tests/init/neg/hybrid4.scala rename to tests/init/warn/hybrid4.scala index 6243fbf2d5f4..8237d0e8244a 100644 --- a/tests/init/neg/hybrid4.scala +++ b/tests/init/warn/hybrid4.scala @@ -8,5 +8,5 @@ class Foo { } val bar: Bar = new Bar - val list = List(1, 2, 3) // error + val list = List(1, 2, 3) // warn } diff --git a/tests/init/neg/hybrid5.scala b/tests/init/warn/hybrid5.scala similarity index 86% rename from tests/init/neg/hybrid5.scala rename to tests/init/warn/hybrid5.scala index 54c781b8835d..4f7f5baad771 100644 --- a/tests/init/neg/hybrid5.scala +++ b/tests/init/warn/hybrid5.scala @@ -15,5 +15,5 @@ class Foo { def g = new Foo.this.Inner } - val list = List(1, 2, 3) // error + val list = List(1, 2, 3) // warn } diff --git a/tests/init/neg/hybrid6.scala b/tests/init/warn/hybrid6.scala similarity index 81% rename from tests/init/neg/hybrid6.scala rename to tests/init/warn/hybrid6.scala index bbecc16942e5..58cbaa76979f 100644 --- a/tests/init/neg/hybrid6.scala +++ b/tests/init/warn/hybrid6.scala @@ -11,5 +11,5 @@ class Foo { def g = list } - val list = List(1, 2, 3) // error + val list = List(1, 2, 3) // warn } diff --git a/tests/init/neg/i10549b.scala b/tests/init/warn/i10549b.scala similarity index 81% rename from tests/init/neg/i10549b.scala rename to tests/init/warn/i10549b.scala index 7353844b3927..b0dd305c7e27 100644 --- a/tests/init/neg/i10549b.scala +++ b/tests/init/warn/i10549b.scala @@ -4,6 +4,6 @@ class Wrap { abstract class E[+T] { def foo: T } object E { final val A: E[Nothing] = new E { def foo = ref } - val ref = qux(A) // error + val ref = qux(A) // warn } } diff --git a/tests/init/neg/i11572.scala b/tests/init/warn/i11572.scala similarity index 90% rename from tests/init/neg/i11572.scala rename to tests/init/warn/i11572.scala index 59fa3c1fbc43..2a32a8bdd540 100644 --- a/tests/init/neg/i11572.scala +++ b/tests/init/warn/i11572.scala @@ -5,7 +5,7 @@ class A { trait Bounded { type T >: Cov[Int] <: Cov[String] } - val t: Bounded = new Bounded { // error + val t: Bounded = new Bounded { // warn // Note: using this instead of t produces an error (as expected) override type T >: t.T <: t.T } diff --git a/tests/init/neg/i12544.scala b/tests/init/warn/i12544.scala similarity index 93% rename from tests/init/neg/i12544.scala rename to tests/init/warn/i12544.scala index 695e57e1d42a..283e0d62203b 100644 --- a/tests/init/neg/i12544.scala +++ b/tests/init/warn/i12544.scala @@ -15,7 +15,7 @@ class Outer: class B() { def foo() = n + 1 } def g(b: B): Int = b.foo() - g(new B()) // error + g(new B()) // warn val n: Int = 10 @main def main(): Unit = { diff --git a/tests/init/neg/i15363.scala b/tests/init/warn/i15363.scala similarity index 78% rename from tests/init/neg/i15363.scala rename to tests/init/warn/i15363.scala index 01a2bdfcf530..87ca08ea916e 100644 --- a/tests/init/neg/i15363.scala +++ b/tests/init/warn/i15363.scala @@ -1,6 +1,6 @@ class A: // should report one error here - val b = new B(this) // error + val b = new B(this) // warn val m = 10 val n = 20 diff --git a/tests/init/neg/i15459.scala b/tests/init/warn/i15459.scala similarity index 81% rename from tests/init/neg/i15459.scala rename to tests/init/warn/i15459.scala index 4d54f31f7af8..72779ef0c7c1 100644 --- a/tests/init/neg/i15459.scala +++ b/tests/init/warn/i15459.scala @@ -1,6 +1,6 @@ class Sup: val a = 10 - println(this) // error + println(this) // warn class Sub extends Sup: val b = 20 diff --git a/tests/init/neg/i4031.scala b/tests/init/warn/i4031.scala similarity index 78% rename from tests/init/neg/i4031.scala rename to tests/init/warn/i4031.scala index ed3f18ac931a..6cb49fcfd93c 100644 --- a/tests/init/neg/i4031.scala +++ b/tests/init/warn/i4031.scala @@ -1,7 +1,7 @@ class App { trait A { type L >: Any} def upcast(a: A, x: Any): a.L = x - val p: A { type L <: Nothing } = p // error + val p: A { type L <: Nothing } = p // warn def coerce(x: Any): Int = upcast(p, x) def main(args: Array[String]): Unit = { diff --git a/tests/init/neg/i4042.scala b/tests/init/warn/i4042.scala similarity index 87% rename from tests/init/neg/i4042.scala rename to tests/init/warn/i4042.scala index 58c884a5690d..284f97a352c9 100644 --- a/tests/init/neg/i4042.scala +++ b/tests/init/warn/i4042.scala @@ -5,7 +5,7 @@ object App { class T[A <: X](val a: A)(val value: a.R) - object O { val x : Y & X = x } // error + object O { val x : Y & X = x } // warn val a = new T[Y & X](O.x)(u) a.value diff --git a/tests/init/neg/i50.scala b/tests/init/warn/i50.scala similarity index 64% rename from tests/init/neg/i50.scala rename to tests/init/warn/i50.scala index 9131fb263f48..7c860bc007fa 100644 --- a/tests/init/neg/i50.scala +++ b/tests/init/warn/i50.scala @@ -1,5 +1,5 @@ class C[T] { val a: T = method def method = b - val b: T = a // error + val b: T = a // warn } \ No newline at end of file diff --git a/tests/init/neg/i5854.scala b/tests/init/warn/i5854.scala similarity index 63% rename from tests/init/neg/i5854.scala rename to tests/init/warn/i5854.scala index 05fa1033dd2c..60060394bdcd 100644 --- a/tests/init/neg/i5854.scala +++ b/tests/init/warn/i5854.scala @@ -1,5 +1,5 @@ class B { val a: String = (((1: Any): b.A): Nothing): String - val b: { type A >: Any <: Nothing } = loop() // error + val b: { type A >: Any <: Nothing } = loop() // warn def loop(): Nothing = loop() } diff --git a/tests/init/neg/inherit-non-hot.scala b/tests/init/warn/inherit-non-hot.scala similarity index 86% rename from tests/init/neg/inherit-non-hot.scala rename to tests/init/warn/inherit-non-hot.scala index 44be67351630..28520ea9c621 100644 --- a/tests/init/neg/inherit-non-hot.scala +++ b/tests/init/warn/inherit-non-hot.scala @@ -3,7 +3,7 @@ object Foo { abstract class A { var b: B = null def toB: B = - if b == null then b = new B(this) // error + if b == null then b = new B(this) // warn b } diff --git a/tests/init/neg/inlined-method.scala b/tests/init/warn/inlined-method.scala similarity index 70% rename from tests/init/neg/inlined-method.scala rename to tests/init/warn/inlined-method.scala index 4af473837f0f..e6ea86ba33c9 100644 --- a/tests/init/neg/inlined-method.scala +++ b/tests/init/warn/inlined-method.scala @@ -5,4 +5,4 @@ class InlineError { object Assertion: transparent inline def failAssert(inline message: => Any): Unit = - scala.runtime.Scala3RunTime.assertFailed(message) // error \ No newline at end of file + scala.runtime.Scala3RunTime.assertFailed(message) // warn \ No newline at end of file diff --git a/tests/init/neg/inner-case.scala b/tests/init/warn/inner-case.scala similarity index 82% rename from tests/init/neg/inner-case.scala rename to tests/init/warn/inner-case.scala index 20a9b1d2684f..317d77376aa9 100644 --- a/tests/init/neg/inner-case.scala +++ b/tests/init/warn/inner-case.scala @@ -4,7 +4,7 @@ class Foo { } val a = Inner(5) // ok - println(a) // error + println(a) // warn var count = 0 println(a) // ok diff --git a/tests/init/neg/inner-first.scala b/tests/init/warn/inner-first.scala similarity index 69% rename from tests/init/neg/inner-first.scala rename to tests/init/warn/inner-first.scala index cd7b28a30b62..be3c7d824dc5 100644 --- a/tests/init/neg/inner-first.scala +++ b/tests/init/warn/inner-first.scala @@ -1,6 +1,6 @@ class A: class B: - println(this) // error + println(this) // warn val n = 10 def foo() = println(m) new B diff --git a/tests/init/neg/inner-loop.scala b/tests/init/warn/inner-loop.scala similarity index 88% rename from tests/init/neg/inner-loop.scala rename to tests/init/warn/inner-loop.scala index c6d5c615580c..8b63eb9507dc 100644 --- a/tests/init/neg/inner-loop.scala +++ b/tests/init/warn/inner-loop.scala @@ -3,7 +3,7 @@ class Outer { outer => val x = 5 + outer.n } val inner = new Inner - val n = 6 // error + val n = 6 // warn } class Outer2 { outer => @@ -28,7 +28,7 @@ class Test { // If we change policy to check more eagerly, // the check has to avoid loop here. - println(outer) // error + println(outer) // warn val m = 10 } \ No newline at end of file diff --git a/tests/init/neg/inner-new.scala b/tests/init/warn/inner-new.scala similarity index 80% rename from tests/init/neg/inner-new.scala rename to tests/init/warn/inner-new.scala index d09dc5193dbf..2ecaf5e544e1 100644 --- a/tests/init/neg/inner-new.scala +++ b/tests/init/warn/inner-new.scala @@ -4,7 +4,7 @@ class Foo { } val a = new Inner // ok - println(a) // error + println(a) // warn var count = 0 println(a) // ok diff --git a/tests/init/neg/inner-pat_iuli.scala b/tests/init/warn/inner-pat_iuli.scala similarity index 92% rename from tests/init/neg/inner-pat_iuli.scala rename to tests/init/warn/inner-pat_iuli.scala index e5010cca98ec..bd84fee43d97 100644 --- a/tests/init/neg/inner-pat_iuli.scala +++ b/tests/init/warn/inner-pat_iuli.scala @@ -20,5 +20,5 @@ trait Blox { self: MyCodes => class MyCodes extends AnyRef with Ops with Blox { val a = b - val b: Int = 10 // error + val b: Int = 10 // warn } diff --git a/tests/init/neg/inner1.scala b/tests/init/warn/inner1.scala similarity index 80% rename from tests/init/neg/inner1.scala rename to tests/init/warn/inner1.scala index d39c3ba2ac77..9220eda882cf 100644 --- a/tests/init/neg/inner1.scala +++ b/tests/init/warn/inner1.scala @@ -1,7 +1,7 @@ class Foo { new this.Inner - val list = List(1, 2, 3) // error, as Inner access `this.list` + val list = List(1, 2, 3) // warn, as Inner access `this.list` val inner: Inner = new this.Inner // ok, `list` is instantiated lib.escape(inner) // ok, can promote inner early diff --git a/tests/init/neg/inner11.scala b/tests/init/warn/inner11.scala similarity index 93% rename from tests/init/neg/inner11.scala rename to tests/init/warn/inner11.scala index 04098be8a3fd..2ea6d25f5d6f 100644 --- a/tests/init/neg/inner11.scala +++ b/tests/init/warn/inner11.scala @@ -12,7 +12,7 @@ object NameKinds { class ClassifiedNameKind(tag: Int, val infoString: String) extends NameKind(tag) { type ThisInfo = Info val info: Info = new Info - println(info.kind) // error + println(info.kind) // warn val n = 10 } } diff --git a/tests/init/neg/inner15.scala b/tests/init/warn/inner15.scala similarity index 84% rename from tests/init/neg/inner15.scala rename to tests/init/warn/inner15.scala index 59d1daac404f..7c01cd8275d7 100644 --- a/tests/init/neg/inner15.scala +++ b/tests/init/warn/inner15.scala @@ -15,5 +15,5 @@ class B extends A { new Inner1 new Inner2 - override val x = "world" // error + override val x = "world" // warn } \ No newline at end of file diff --git a/tests/init/neg/inner16.scala b/tests/init/warn/inner16.scala similarity index 87% rename from tests/init/neg/inner16.scala rename to tests/init/warn/inner16.scala index 61271396a074..c49cba8a88be 100644 --- a/tests/init/neg/inner16.scala +++ b/tests/init/warn/inner16.scala @@ -13,5 +13,5 @@ class A { val inner = new Inner val b = new O.B - val y = 10 // error + val y = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner17.scala b/tests/init/warn/inner17.scala similarity index 78% rename from tests/init/neg/inner17.scala rename to tests/init/warn/inner17.scala index 756278cd5130..4daad38ea36b 100644 --- a/tests/init/neg/inner17.scala +++ b/tests/init/warn/inner17.scala @@ -9,5 +9,5 @@ class A { } class C extends A { - override val f: Int = 20 // error + override val f: Int = 20 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner19.scala b/tests/init/warn/inner19.scala similarity index 79% rename from tests/init/neg/inner19.scala rename to tests/init/warn/inner19.scala index 2e502eddc24c..91cf406dbc6a 100644 --- a/tests/init/neg/inner19.scala +++ b/tests/init/warn/inner19.scala @@ -15,5 +15,5 @@ class A { class B extends A { println((new O.B).f) O.C(4) - override val n = 50 // error because line 16 + override val n = 50 // warn because line 16 } \ No newline at end of file diff --git a/tests/init/neg/inner20.scala b/tests/init/warn/inner20.scala similarity index 84% rename from tests/init/neg/inner20.scala rename to tests/init/warn/inner20.scala index 1553e09eeeb0..2a868f8b88f5 100644 --- a/tests/init/neg/inner20.scala +++ b/tests/init/warn/inner20.scala @@ -14,5 +14,5 @@ class A { class B extends A { val o = new O println((new o.B).f) - override val n = 50 // error + override val n = 50 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner21.scala b/tests/init/warn/inner21.scala similarity index 71% rename from tests/init/neg/inner21.scala rename to tests/init/warn/inner21.scala index c2277163acc3..232de8fbd0cc 100644 --- a/tests/init/neg/inner21.scala +++ b/tests/init/warn/inner21.scala @@ -8,7 +8,7 @@ class X { A.foo A.bar - val name = "jack" // error + val name = "jack" // warn } @@ -22,5 +22,5 @@ class Y { (new A).foo (new A).bar - val name = "jack" // error + val name = "jack" // warn } \ No newline at end of file diff --git a/tests/init/neg/inner22.scala b/tests/init/warn/inner22.scala similarity index 92% rename from tests/init/neg/inner22.scala rename to tests/init/warn/inner22.scala index aa5a381f2d49..055a9d9bed7d 100644 --- a/tests/init/neg/inner22.scala +++ b/tests/init/warn/inner22.scala @@ -28,5 +28,5 @@ class D { new C - val x = 10 // error + val x = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner23.scala b/tests/init/warn/inner23.scala similarity index 77% rename from tests/init/neg/inner23.scala rename to tests/init/warn/inner23.scala index 5d373c649ce2..a5985a8d805c 100644 --- a/tests/init/neg/inner23.scala +++ b/tests/init/warn/inner23.scala @@ -9,5 +9,5 @@ class Trees { } val theEmptyValDef = new EmptyValDef - val name = "hello" // error + val name = "hello" // warn } diff --git a/tests/init/neg/inner24.scala b/tests/init/warn/inner24.scala similarity index 84% rename from tests/init/neg/inner24.scala rename to tests/init/warn/inner24.scala index f8a60c1bb311..3c28546b10cc 100644 --- a/tests/init/neg/inner24.scala +++ b/tests/init/warn/inner24.scala @@ -14,5 +14,5 @@ class Bar extends Foo { val b = new B override def foo(x: Int) = x + id - val id = 100 // error + val id = 100 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner25.scala b/tests/init/warn/inner25.scala similarity index 91% rename from tests/init/neg/inner25.scala rename to tests/init/warn/inner25.scala index 8cf99539b849..a9538dee6462 100644 --- a/tests/init/neg/inner25.scala +++ b/tests/init/warn/inner25.scala @@ -8,7 +8,7 @@ class A[K, V] { self => } } - println(new O) // error + println(new O) // warn val a = 10 } \ No newline at end of file diff --git a/tests/init/neg/inner29.scala b/tests/init/warn/inner29.scala similarity index 83% rename from tests/init/neg/inner29.scala rename to tests/init/warn/inner29.scala index 740352db1e4e..03350a5266b8 100644 --- a/tests/init/neg/inner29.scala +++ b/tests/init/warn/inner29.scala @@ -15,7 +15,7 @@ class C extends B(5) { override def f: Int = x } - val a = new E // error: init too late + val a = new E // warn: init too late val x = 10 } \ No newline at end of file diff --git a/tests/init/neg/inner30.scala b/tests/init/warn/inner30.scala similarity index 92% rename from tests/init/neg/inner30.scala rename to tests/init/warn/inner30.scala index 87d8888437da..d9b1eec3d6b1 100644 --- a/tests/init/neg/inner30.scala +++ b/tests/init/warn/inner30.scala @@ -17,5 +17,5 @@ class Scanners { } val m: Int = n * 2 - val n = 10 // error + val n = 10 // warn } \ No newline at end of file diff --git a/tests/init/neg/inner4.scala b/tests/init/warn/inner4.scala similarity index 77% rename from tests/init/neg/inner4.scala rename to tests/init/warn/inner4.scala index 5fc4d2b9e053..66a39da03909 100644 --- a/tests/init/neg/inner4.scala +++ b/tests/init/warn/inner4.scala @@ -6,5 +6,5 @@ class Foo(val foo1: Foo) { new this.Inner new foo1.Inner - val name = "hello" // error + val name = "hello" // warn } diff --git a/tests/init/neg/inner5.scala b/tests/init/warn/inner5.scala similarity index 76% rename from tests/init/neg/inner5.scala rename to tests/init/warn/inner5.scala index 20f4aa1bdaeb..f91573e98cb6 100644 --- a/tests/init/neg/inner5.scala +++ b/tests/init/warn/inner5.scala @@ -4,7 +4,7 @@ class Foo { } new B - val a = 3 // error + val a = 3 // warn def foo(x: Int) = a + x } \ No newline at end of file diff --git a/tests/init/neg/inner6.scala b/tests/init/warn/inner6.scala similarity index 91% rename from tests/init/neg/inner6.scala rename to tests/init/warn/inner6.scala index 42b68fe2d8ea..7f0436dc6924 100644 --- a/tests/init/neg/inner6.scala +++ b/tests/init/warn/inner6.scala @@ -18,6 +18,6 @@ class Child extends Parent { new InnerA new InnerB - val x = 10 // error + val x = 10 // warn override def foo: Int = x * x } diff --git a/tests/init/neg/inner7.scala b/tests/init/warn/inner7.scala similarity index 81% rename from tests/init/neg/inner7.scala rename to tests/init/warn/inner7.scala index bdac38cc31d8..5e0df53f0888 100644 --- a/tests/init/neg/inner7.scala +++ b/tests/init/warn/inner7.scala @@ -11,6 +11,6 @@ class Child extends Parent { class InnerA extends Inner1 new InnerA - override val list = List(4, 5) // error + override val list = List(4, 5) // warn override def foo: Int = list.size } diff --git a/tests/init/neg/inner9.scala b/tests/init/warn/inner9.scala similarity index 79% rename from tests/init/neg/inner9.scala rename to tests/init/warn/inner9.scala index b572c8cb49d3..64e83ead0b07 100644 --- a/tests/init/neg/inner9.scala +++ b/tests/init/warn/inner9.scala @@ -1,5 +1,5 @@ class Outer: - val flags = new Flags // error + val flags = new Flags // warn class Flags { class Inner { @@ -9,7 +9,7 @@ class Outer: new flags.Inner val a = this.b + 3 - val b = 5 // error + val b = 5 // warn } class Flags2 { diff --git a/tests/init/neg/insert-cold-subtype-to-array.scala b/tests/init/warn/insert-cold-subtype-to-array.scala similarity index 84% rename from tests/init/neg/insert-cold-subtype-to-array.scala rename to tests/init/warn/insert-cold-subtype-to-array.scala index 82eee1935a95..6f4bf9bca73e 100644 --- a/tests/init/neg/insert-cold-subtype-to-array.scala +++ b/tests/init/warn/insert-cold-subtype-to-array.scala @@ -3,6 +3,6 @@ object A: class B: var a = new Array[B](2) - A.foo(this, a) // error + A.foo(this, a) // warn println(a(0).i) val i = 99 \ No newline at end of file diff --git a/tests/init/neg/java1.scala b/tests/init/warn/java1.scala similarity index 91% rename from tests/init/neg/java1.scala rename to tests/init/warn/java1.scala index 1eff09cb6ff1..36044413d2ea 100644 --- a/tests/init/neg/java1.scala +++ b/tests/init/warn/java1.scala @@ -8,4 +8,4 @@ class A extends Spliterator.OfDouble: def tryAdvance(x$0: java.util.function.DoubleConsumer): Boolean = false val m = n + 1 - val n = 10 // error + val n = 10 // warn diff --git a/tests/init/neg/lazy.scala b/tests/init/warn/lazy.scala similarity index 69% rename from tests/init/neg/lazy.scala rename to tests/init/warn/lazy.scala index 0f3047bc0d1b..a895714b0f9a 100644 --- a/tests/init/neg/lazy.scala +++ b/tests/init/warn/lazy.scala @@ -1,11 +1,11 @@ class Foo { val len = list.size - val list = List(4, 6) // error + val list = List(4, 6) // warn lazy val len2 = list2.size // ok val list2 = List(4, 6) lazy val len3 = name.size val len4 = len3 + 4 - val name = "hello" // error + val name = "hello" // warn } diff --git a/tests/init/neg/lazylist2.scala b/tests/init/warn/lazylist2.scala similarity index 89% rename from tests/init/neg/lazylist2.scala rename to tests/init/warn/lazylist2.scala index 18072676fa4c..618364f49a98 100644 --- a/tests/init/neg/lazylist2.scala +++ b/tests/init/warn/lazylist2.scala @@ -26,7 +26,7 @@ final class Test1 { a.head // ok b.head // ok - val x: LazyList[Int] = 5 #:: y // error + val x: LazyList[Int] = 5 #:: y // warn val y: LazyList[Int] = 10 #:: x } @@ -37,7 +37,7 @@ final class Test2 { } final class Test3 { - val a: LazyList[Int] = n #:: (a: @unchecked) // error + val a: LazyList[Int] = n #:: (a: @unchecked) // warn a.head val n: Int = 20 } \ No newline at end of file diff --git a/tests/init/neg/leak-warm.scala b/tests/init/warn/leak-warm.scala similarity index 91% rename from tests/init/neg/leak-warm.scala rename to tests/init/warn/leak-warm.scala index 9bfbe2e4f285..5278b67e7eac 100644 --- a/tests/init/neg/leak-warm.scala +++ b/tests/init/warn/leak-warm.scala @@ -16,5 +16,5 @@ class leakWarm { val c = new C(1, 2) val d = new D(3, 4) val l: List[A] = List(c, d) - val l2 = l.map(_.m()) // error + val l2 = l.map(_.m()) // warn } diff --git a/tests/init/neg/local-class.scala b/tests/init/warn/local-class.scala similarity index 84% rename from tests/init/neg/local-class.scala rename to tests/init/warn/local-class.scala index 20e77912dce8..14f203a738c3 100644 --- a/tests/init/neg/local-class.scala +++ b/tests/init/warn/local-class.scala @@ -12,5 +12,5 @@ class Outer { foo - val n = 10 // error + val n = 10 // warn } diff --git a/tests/init/neg/override1.scala b/tests/init/warn/override1.scala similarity index 84% rename from tests/init/neg/override1.scala rename to tests/init/warn/override1.scala index c9c9fed3ecd8..b247470c19d5 100644 --- a/tests/init/neg/override1.scala +++ b/tests/init/warn/override1.scala @@ -15,6 +15,6 @@ class Qux(x: Int) extends Bar { } class Yun extends Bar { - override val x: Int = 10 // error + override val x: Int = 10 // warn def foo(n: Int) = x + n } diff --git a/tests/init/neg/override10.scala b/tests/init/warn/override10.scala similarity index 75% rename from tests/init/neg/override10.scala rename to tests/init/warn/override10.scala index 6b8b0e7101db..0c49d7c63113 100644 --- a/tests/init/neg/override10.scala +++ b/tests/init/warn/override10.scala @@ -5,5 +5,5 @@ trait Foo { class Bar extends Foo { f() - val message = "hello" // error + val message = "hello" // warn } \ No newline at end of file diff --git a/tests/init/neg/override14.scala b/tests/init/warn/override14.scala similarity index 76% rename from tests/init/neg/override14.scala rename to tests/init/warn/override14.scala index 451a12087103..0d773e61f9b2 100644 --- a/tests/init/neg/override14.scala +++ b/tests/init/warn/override14.scala @@ -1,5 +1,5 @@ abstract class A { - val x = f(this) // error + val x = f(this) // warn val y = 10 def f(a: A): Int diff --git a/tests/init/neg/override15.scala b/tests/init/warn/override15.scala similarity index 81% rename from tests/init/neg/override15.scala rename to tests/init/warn/override15.scala index 0f22430cf6a6..ca3e32abb35e 100644 --- a/tests/init/neg/override15.scala +++ b/tests/init/warn/override15.scala @@ -1,6 +1,6 @@ abstract class A { val g = (n: Int) => n + y - val x: Int = f(g) // error + val x: Int = f(g) // warn val y: Int = 10 def f(m: Int => Int): Int diff --git a/tests/init/neg/override17.scala b/tests/init/warn/override17.scala similarity index 76% rename from tests/init/neg/override17.scala rename to tests/init/warn/override17.scala index 72bd8db9a246..cbeaaed37bea 100644 --- a/tests/init/neg/override17.scala +++ b/tests/init/warn/override17.scala @@ -3,7 +3,7 @@ class A { self : B => } trait B { - val x = 10 // error + val x = 10 // warn } class C extends A with B diff --git a/tests/init/neg/override18.scala b/tests/init/warn/override18.scala similarity index 88% rename from tests/init/neg/override18.scala rename to tests/init/warn/override18.scala index 61edaf6d8c8f..3c2ca3e7af5d 100644 --- a/tests/init/neg/override18.scala +++ b/tests/init/warn/override18.scala @@ -10,7 +10,7 @@ class B extends A { class C extends A { val x = f - val y = x // error + val y = x // warn def f: Int = y } diff --git a/tests/init/neg/override19.scala b/tests/init/warn/override19.scala similarity index 79% rename from tests/init/neg/override19.scala rename to tests/init/warn/override19.scala index 8e1f6a832323..61d17bb93597 100644 --- a/tests/init/neg/override19.scala +++ b/tests/init/warn/override19.scala @@ -5,6 +5,6 @@ abstract class A extends Product { case class B(x: Int, y: String) extends A case class C(x: Int) extends A { - val y = 10 // error + val y = 10 // warn def productArity: Int = y } \ No newline at end of file diff --git a/tests/init/neg/override2.scala b/tests/init/warn/override2.scala similarity index 89% rename from tests/init/neg/override2.scala rename to tests/init/warn/override2.scala index f9964f60ad29..3adae93c23c9 100644 --- a/tests/init/neg/override2.scala +++ b/tests/init/warn/override2.scala @@ -8,7 +8,7 @@ trait Foo { } class Bar extends Foo { - val y = "hello" // error + val y = "hello" // warn foo(5) bar(10) diff --git a/tests/init/neg/override20.scala b/tests/init/warn/override20.scala similarity index 75% rename from tests/init/neg/override20.scala rename to tests/init/warn/override20.scala index 65ece64c6020..4f1f7b452f75 100644 --- a/tests/init/neg/override20.scala +++ b/tests/init/warn/override20.scala @@ -2,7 +2,7 @@ class A { self : B => val y = f } -trait B(x: Int) { // error +trait B(x: Int) { // warn def f: Int = x } diff --git a/tests/init/neg/override21.scala b/tests/init/warn/override21.scala similarity index 86% rename from tests/init/neg/override21.scala rename to tests/init/warn/override21.scala index 332ce702a9fc..84c319949cb7 100644 --- a/tests/init/neg/override21.scala +++ b/tests/init/warn/override21.scala @@ -10,7 +10,7 @@ class Child extends Parent { this.z val m = this.x - val y = "hello" // error + val y = "hello" // warn def bar = y.size } \ No newline at end of file diff --git a/tests/init/neg/override22.scala b/tests/init/warn/override22.scala similarity index 87% rename from tests/init/neg/override22.scala rename to tests/init/warn/override22.scala index 7de6f03aa837..f7fc1b312e4e 100644 --- a/tests/init/neg/override22.scala +++ b/tests/init/warn/override22.scala @@ -9,7 +9,7 @@ class Child extends Parent { val y = "hello" this.foo - val m = this.x // error + val m = this.x // warn this.z def bar = m.size + 6 diff --git a/tests/init/neg/override23.scala b/tests/init/warn/override23.scala similarity index 87% rename from tests/init/neg/override23.scala rename to tests/init/warn/override23.scala index 3ada767bfafc..2af45c953ae5 100644 --- a/tests/init/neg/override23.scala +++ b/tests/init/warn/override23.scala @@ -10,7 +10,7 @@ class Child(o: String) extends Parent(o) { this.foo this.z - val y = "hello" // error + val y = "hello" // warn def bar = y.size } \ No newline at end of file diff --git a/tests/init/neg/override24.scala b/tests/init/warn/override24.scala similarity index 91% rename from tests/init/neg/override24.scala rename to tests/init/warn/override24.scala index 9adfac27bb02..feaa07396755 100644 --- a/tests/init/neg/override24.scala +++ b/tests/init/warn/override24.scala @@ -15,7 +15,7 @@ class Bar extends Foo { foo(4) - val name = "bar" // error + val name = "bar" // warn foo(4) } \ No newline at end of file diff --git a/tests/init/neg/override25.scala b/tests/init/warn/override25.scala similarity index 85% rename from tests/init/neg/override25.scala rename to tests/init/warn/override25.scala index 9554b4296a9f..e5d5d7f8e34f 100644 --- a/tests/init/neg/override25.scala +++ b/tests/init/warn/override25.scala @@ -1,4 +1,4 @@ -trait Foo(x: Int) { // error +trait Foo(x: Int) { // warn def name: String = "hello" def f: Int = x diff --git a/tests/init/neg/override26.scala b/tests/init/warn/override26.scala similarity index 85% rename from tests/init/neg/override26.scala rename to tests/init/warn/override26.scala index 37e83898bfcc..98a30477ee74 100644 --- a/tests/init/neg/override26.scala +++ b/tests/init/warn/override26.scala @@ -11,6 +11,6 @@ trait Bar { this: Foo => } class Qux extends Foo with Bar { - val x = "hello" // error + val x = "hello" // warn def title = x } diff --git a/tests/init/neg/override27.scala b/tests/init/warn/override27.scala similarity index 73% rename from tests/init/neg/override27.scala rename to tests/init/warn/override27.scala index 4b3a79ac233b..ae9ffe6ad63f 100644 --- a/tests/init/neg/override27.scala +++ b/tests/init/warn/override27.scala @@ -1,6 +1,6 @@ abstract class Base { def f: Int - val a = f // error + val a = f // warn } class Derived extends Base { @@ -10,7 +10,7 @@ class Derived extends Base { } class Derived2 extends Base { - val b = 30 // error + val b = 30 // warn def f = g def g: Int = b + a diff --git a/tests/init/neg/override28.scala b/tests/init/warn/override28.scala similarity index 72% rename from tests/init/neg/override28.scala rename to tests/init/warn/override28.scala index 8e77f8acb3ba..60ba0bff6c76 100644 --- a/tests/init/neg/override28.scala +++ b/tests/init/warn/override28.scala @@ -6,5 +6,5 @@ abstract class Base(val x: Int) { class C(x: Int) extends Base(x) { - val d = f // error + val d = f // warn } \ No newline at end of file diff --git a/tests/init/neg/override29.scala b/tests/init/warn/override29.scala similarity index 78% rename from tests/init/neg/override29.scala rename to tests/init/warn/override29.scala index e0070eb10218..5c640e2fcc0e 100644 --- a/tests/init/neg/override29.scala +++ b/tests/init/warn/override29.scala @@ -1,5 +1,5 @@ trait A { - var a = 20 // error + var a = 20 // warn def f: Int = a } diff --git a/tests/init/neg/override3.scala b/tests/init/warn/override3.scala similarity index 91% rename from tests/init/neg/override3.scala rename to tests/init/warn/override3.scala index 51759320e1b5..74fae84a547a 100644 --- a/tests/init/neg/override3.scala +++ b/tests/init/warn/override3.scala @@ -13,7 +13,7 @@ class Bar1 extends Foo { } class Qux extends Bar1 { - val u = "hello" // error + val u = "hello" // warn override def foo(n: Int) = u + "world" } diff --git a/tests/init/neg/override30.scala b/tests/init/warn/override30.scala similarity index 79% rename from tests/init/neg/override30.scala rename to tests/init/warn/override30.scala index adb4c2e00d2b..1677574130d4 100644 --- a/tests/init/neg/override30.scala +++ b/tests/init/warn/override30.scala @@ -10,6 +10,6 @@ class Bar extends Foo { } class Qux extends Bar { - val a = 30 // error + val a = 30 // warn override def f = a } \ No newline at end of file diff --git a/tests/init/neg/override31.scala b/tests/init/warn/override31.scala similarity index 84% rename from tests/init/neg/override31.scala rename to tests/init/warn/override31.scala index d902f4a6dc54..baffab3ad08e 100644 --- a/tests/init/neg/override31.scala +++ b/tests/init/warn/override31.scala @@ -11,5 +11,5 @@ class Bar extends Foo { class Qux extends Bar { init override def f = a - private val a = 30 // error + private val a = 30 // warn } \ No newline at end of file diff --git a/tests/init/neg/override32.scala b/tests/init/warn/override32.scala similarity index 80% rename from tests/init/neg/override32.scala rename to tests/init/warn/override32.scala index 09970a9bd392..b9a4e7eae178 100644 --- a/tests/init/neg/override32.scala +++ b/tests/init/warn/override32.scala @@ -6,7 +6,7 @@ trait Foo { } trait Bar { - final val m: String = "hello" // error + final val m: String = "hello" // warn def foo(n: Int) = m } diff --git a/tests/init/neg/override33.scala b/tests/init/warn/override33.scala similarity index 85% rename from tests/init/neg/override33.scala rename to tests/init/warn/override33.scala index b093dc570f04..04d27be6777c 100644 --- a/tests/init/neg/override33.scala +++ b/tests/init/warn/override33.scala @@ -8,7 +8,7 @@ abstract class Foo { } trait Bar { - val name: String = "Foo" // error + val name: String = "Foo" // warn def title: String = name } diff --git a/tests/init/neg/override34.scala b/tests/init/warn/override34.scala similarity index 79% rename from tests/init/neg/override34.scala rename to tests/init/warn/override34.scala index 6cf3e3cf4b4d..e4a21e861eb2 100644 --- a/tests/init/neg/override34.scala +++ b/tests/init/warn/override34.scala @@ -5,7 +5,7 @@ abstract class Foo { } trait Bar { - val name: String = "Foo" // error + val name: String = "Foo" // warn } class Qux extends Foo with Bar { diff --git a/tests/init/neg/override35.scala b/tests/init/warn/override35.scala similarity index 77% rename from tests/init/neg/override35.scala rename to tests/init/warn/override35.scala index 958ed1ff9d2f..1769f7b3a361 100644 --- a/tests/init/neg/override35.scala +++ b/tests/init/warn/override35.scala @@ -10,6 +10,6 @@ trait Bar { } class Qux extends Foo with Bar { - private val x = 30 // error + private val x = 30 // warn override def f = x } \ No newline at end of file diff --git a/tests/init/neg/override36.scala b/tests/init/warn/override36.scala similarity index 87% rename from tests/init/neg/override36.scala rename to tests/init/warn/override36.scala index 6df0891d5b27..2fedf7ff6bcb 100644 --- a/tests/init/neg/override36.scala +++ b/tests/init/warn/override36.scala @@ -14,5 +14,5 @@ class Bar extends Foo { class Qux extends Bar { init override def h = a - private val a = 30 // error + private val a = 30 // warn } \ No newline at end of file diff --git a/tests/init/neg/override38.scala b/tests/init/warn/override38.scala similarity index 77% rename from tests/init/neg/override38.scala rename to tests/init/warn/override38.scala index dd47b0438980..feb962cd5029 100644 --- a/tests/init/neg/override38.scala +++ b/tests/init/warn/override38.scala @@ -1,7 +1,7 @@ abstract class A { def f: Int - (1 to 10).foreach { i => // error + (1 to 10).foreach { i => // warn f } diff --git a/tests/init/neg/override39.scala b/tests/init/warn/override39.scala similarity index 82% rename from tests/init/neg/override39.scala rename to tests/init/warn/override39.scala index 723e71554da2..34f25cee2022 100644 --- a/tests/init/neg/override39.scala +++ b/tests/init/warn/override39.scala @@ -6,6 +6,6 @@ abstract class Parent extends Product { } case class Child(x: Int) extends Parent { - val m = 10 // error + val m = 10 // warn def productArity: Int = m } \ No newline at end of file diff --git a/tests/init/neg/override4.scala b/tests/init/warn/override4.scala similarity index 82% rename from tests/init/neg/override4.scala rename to tests/init/warn/override4.scala index 1489e1c2508b..1a63d2b3b59b 100644 --- a/tests/init/neg/override4.scala +++ b/tests/init/warn/override4.scala @@ -12,7 +12,7 @@ class Bar extends Foo { } class Bar2 extends Bar { - val mymap: mutable.Map[Int, String] = mutable.Map.empty // error + val mymap: mutable.Map[Int, String] = mutable.Map.empty // warn override def enter(k: Int, v: String) = { mymap(k) = v diff --git a/tests/init/neg/override40.scala b/tests/init/warn/override40.scala similarity index 80% rename from tests/init/neg/override40.scala rename to tests/init/warn/override40.scala index 2f081a9de30b..305210158d54 100644 --- a/tests/init/neg/override40.scala +++ b/tests/init/warn/override40.scala @@ -6,5 +6,5 @@ abstract class A { class B extends A { this.getClass f - val a = 20 // error + val a = 20 // warn } \ No newline at end of file diff --git a/tests/init/neg/override41.scala b/tests/init/warn/override41.scala similarity index 82% rename from tests/init/neg/override41.scala rename to tests/init/warn/override41.scala index bfd5bc18f3d6..6cb58ae326aa 100644 --- a/tests/init/neg/override41.scala +++ b/tests/init/warn/override41.scala @@ -11,5 +11,5 @@ class Child extends Parent { def show = println(name) - val name = "child" // error + val name = "child" // warn } \ No newline at end of file diff --git a/tests/init/neg/override42.scala b/tests/init/warn/override42.scala similarity index 81% rename from tests/init/neg/override42.scala rename to tests/init/warn/override42.scala index b4a53b977852..39a4d5097215 100644 --- a/tests/init/neg/override42.scala +++ b/tests/init/warn/override42.scala @@ -12,5 +12,5 @@ class Bar { def show = println(name) - val name = "child" // error + val name = "child" // warn } diff --git a/tests/init/neg/override43.scala b/tests/init/warn/override43.scala similarity index 83% rename from tests/init/neg/override43.scala rename to tests/init/warn/override43.scala index 2d55742c3ecd..ab8ec95133d6 100644 --- a/tests/init/neg/override43.scala +++ b/tests/init/warn/override43.scala @@ -8,6 +8,6 @@ final class Child extends Parent { def g() = foo() g() + b - val b = 10 // error + val b = 10 // warn g() } \ No newline at end of file diff --git a/tests/init/neg/override44.scala b/tests/init/warn/override44.scala similarity index 83% rename from tests/init/neg/override44.scala rename to tests/init/warn/override44.scala index ed7a0ae30b7a..50e7691d6fee 100644 --- a/tests/init/neg/override44.scala +++ b/tests/init/warn/override44.scala @@ -8,6 +8,6 @@ class Child extends Parent { def g() = foo() g() + b - val b = 10 // error + val b = 10 // warn g() } \ No newline at end of file diff --git a/tests/init/neg/override45.scala b/tests/init/warn/override45.scala similarity index 81% rename from tests/init/neg/override45.scala rename to tests/init/warn/override45.scala index dbf767239e6b..7eb0ba2f8cca 100644 --- a/tests/init/neg/override45.scala +++ b/tests/init/warn/override45.scala @@ -8,5 +8,5 @@ class Child extends Parent { val x = a val y = b override def f: Int = z - val z = 30 // error + val z = 30 // warn } \ No newline at end of file diff --git a/tests/init/neg/override46.scala b/tests/init/warn/override46.scala similarity index 75% rename from tests/init/neg/override46.scala rename to tests/init/warn/override46.scala index 397ec85a6984..f10d4516439c 100644 --- a/tests/init/neg/override46.scala +++ b/tests/init/warn/override46.scala @@ -1,5 +1,5 @@ trait TA { - val x = "world" // error + val x = "world" // warn } trait TB { this: TA => diff --git a/tests/init/neg/override5.scala b/tests/init/warn/override5.scala similarity index 78% rename from tests/init/neg/override5.scala rename to tests/init/warn/override5.scala index 061a41dc3fc2..fe9e3bfbde70 100644 --- a/tests/init/neg/override5.scala +++ b/tests/init/warn/override5.scala @@ -5,7 +5,7 @@ trait Foo { } class Bar extends Foo { - val name = "Jack" // error + val name = "Jack" // warn } @@ -16,7 +16,7 @@ trait Zen { } class Tao extends Zen { - val name = "Jack" // error + val name = "Jack" // warn } diff --git a/tests/init/neg/override6.scala b/tests/init/warn/override6.scala similarity index 70% rename from tests/init/neg/override6.scala rename to tests/init/warn/override6.scala index 0c04ea91300d..e8103d999151 100644 --- a/tests/init/neg/override6.scala +++ b/tests/init/warn/override6.scala @@ -4,5 +4,5 @@ trait Foo { } class Bar extends Foo { - val name = "Jack" // error + val name = "Jack" // warn } \ No newline at end of file diff --git a/tests/init/neg/override7.scala b/tests/init/warn/override7.scala similarity index 87% rename from tests/init/neg/override7.scala rename to tests/init/warn/override7.scala index 0a36f02b2790..41fbcd00be69 100644 --- a/tests/init/neg/override7.scala +++ b/tests/init/warn/override7.scala @@ -7,7 +7,7 @@ trait Foo { } class Bar(val name: String) extends Foo { - val title = "Mr." // error + val title = "Mr." // warn def getName = name // ok: name is a Param field diff --git a/tests/init/neg/override8.scala b/tests/init/warn/override8.scala similarity index 93% rename from tests/init/neg/override8.scala rename to tests/init/warn/override8.scala index 526fd5a7f3a3..272143011efc 100644 --- a/tests/init/neg/override8.scala +++ b/tests/init/warn/override8.scala @@ -6,7 +6,7 @@ trait Foo { } trait Bar { - val m = "hello" // error + val m = "hello" // warn def foo(n: Int) = m diff --git a/tests/init/neg/override9.scala b/tests/init/warn/override9.scala similarity index 64% rename from tests/init/neg/override9.scala rename to tests/init/warn/override9.scala index 1b4d32b3e5a3..12dbfde19ec3 100644 --- a/tests/init/neg/override9.scala +++ b/tests/init/warn/override9.scala @@ -1,6 +1,6 @@ trait Foo { def name: String - val message = "hello, " + name // error + val message = "hello, " + name // warn } class Bar extends Foo { diff --git a/tests/init/neg/polyfun.scala b/tests/init/warn/polyfun.scala similarity index 72% rename from tests/init/neg/polyfun.scala rename to tests/init/warn/polyfun.scala index a3a3ecc76814..5ac11721c061 100644 --- a/tests/init/neg/polyfun.scala +++ b/tests/init/warn/polyfun.scala @@ -4,5 +4,5 @@ class Test { println(n) arg } - val n = m.apply(arg = 23) // error + val n = m.apply(arg = 23) // warn } diff --git a/tests/init/neg/private.scala b/tests/init/warn/private.scala similarity index 84% rename from tests/init/neg/private.scala rename to tests/init/warn/private.scala index 658860ab577c..215f0db3deee 100644 --- a/tests/init/neg/private.scala +++ b/tests/init/warn/private.scala @@ -6,7 +6,7 @@ class A(a: Int) { class B extends A(3) { foo() println(a) - val a = 3 // error + val a = 3 // warn } class C extends A(3) { diff --git a/tests/init/neg/promote-warm.scala b/tests/init/warn/promote-warm.scala similarity index 84% rename from tests/init/neg/promote-warm.scala rename to tests/init/warn/promote-warm.scala index c9f9268f1fbd..c776d37a924e 100644 --- a/tests/init/neg/promote-warm.scala +++ b/tests/init/warn/promote-warm.scala @@ -6,7 +6,7 @@ class PromoteWarm: a.foo() val a = new A - val b = new B(a) // error + val b = new B(a) // warn val n = 10 def foo() = println(n) diff --git a/tests/init/neg/promote.scala b/tests/init/warn/promote.scala similarity index 82% rename from tests/init/neg/promote.scala rename to tests/init/warn/promote.scala index 70e951d78f6f..a97122d57a62 100644 --- a/tests/init/neg/promote.scala +++ b/tests/init/warn/promote.scala @@ -4,6 +4,6 @@ class Wrap { abstract class E[+T] { def foo: T } object E { final val A: E[Nothing] = new E { def foo = ref } - val ref = qux(A) // error + val ref = qux(A) // warn } } \ No newline at end of file diff --git a/tests/init/neg/promotion-loop.scala b/tests/init/warn/promotion-loop.scala similarity index 86% rename from tests/init/neg/promotion-loop.scala rename to tests/init/warn/promotion-loop.scala index 7f6856c34cae..c94422daca76 100644 --- a/tests/init/neg/promotion-loop.scala +++ b/tests/init/warn/promotion-loop.scala @@ -13,7 +13,7 @@ class Test { test => } val b = new B - println(b) // error + println(b) // warn val n = 10 } \ No newline at end of file diff --git a/tests/init/neg/promotion-segment.scala b/tests/init/warn/promotion-segment.scala similarity index 85% rename from tests/init/neg/promotion-segment.scala rename to tests/init/warn/promotion-segment.scala index 56968ce79c56..542ee23623f1 100644 --- a/tests/init/neg/promotion-segment.scala +++ b/tests/init/warn/promotion-segment.scala @@ -8,5 +8,5 @@ class Outer: def bar(c: C) = c.foo() - bar(new C) // error + bar(new C) // warn val m = 10 diff --git a/tests/init/neg/promotion-segment2.scala b/tests/init/warn/promotion-segment2.scala similarity index 87% rename from tests/init/neg/promotion-segment2.scala rename to tests/init/warn/promotion-segment2.scala index d3ba8dedf0ce..39cd7129950f 100644 --- a/tests/init/neg/promotion-segment2.scala +++ b/tests/init/warn/promotion-segment2.scala @@ -8,5 +8,5 @@ class Outer: def bar(c: C) = c.foo() - bar(new C) // error + bar(new C) // warn val m = 10 diff --git a/tests/init/neg/promotion-segment3.scala b/tests/init/warn/promotion-segment3.scala similarity index 82% rename from tests/init/neg/promotion-segment3.scala rename to tests/init/warn/promotion-segment3.scala index 9e62291953d3..5dab2224743b 100644 --- a/tests/init/neg/promotion-segment3.scala +++ b/tests/init/warn/promotion-segment3.scala @@ -6,6 +6,6 @@ class A: def bar(b: B) = new b.C().foo() - bar(new B) // error + bar(new B) // warn val m = 10 diff --git a/tests/init/neg/secondary-ctor.scala b/tests/init/warn/secondary-ctor.scala similarity index 87% rename from tests/init/neg/secondary-ctor.scala rename to tests/init/warn/secondary-ctor.scala index d96e149529d0..92a77b11b57a 100644 --- a/tests/init/neg/secondary-ctor.scala +++ b/tests/init/warn/secondary-ctor.scala @@ -15,5 +15,5 @@ class C(b: B) extends A(b) { class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } diff --git a/tests/init/neg/secondary-ctor2.scala b/tests/init/warn/secondary-ctor2.scala similarity index 91% rename from tests/init/neg/secondary-ctor2.scala rename to tests/init/warn/secondary-ctor2.scala index 462ff2dbcfaa..5518bbf974e7 100644 --- a/tests/init/neg/secondary-ctor2.scala +++ b/tests/init/warn/secondary-ctor2.scala @@ -21,5 +21,5 @@ class C(b: B) extends A(b) { class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } diff --git a/tests/init/neg/secondary-ctor3.scala b/tests/init/warn/secondary-ctor3.scala similarity index 94% rename from tests/init/neg/secondary-ctor3.scala rename to tests/init/warn/secondary-ctor3.scala index 3bbfc413e262..ed01c6fcbe30 100644 --- a/tests/init/neg/secondary-ctor3.scala +++ b/tests/init/warn/secondary-ctor3.scala @@ -35,5 +35,5 @@ def foo() = class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } diff --git a/tests/init/neg/secondary-ctor4.check b/tests/init/warn/secondary-ctor4.check similarity index 84% rename from tests/init/neg/secondary-ctor4.check rename to tests/init/warn/secondary-ctor4.check index 2c89cfe9f289..3909af5ac336 100644 --- a/tests/init/neg/secondary-ctor4.check +++ b/tests/init/warn/secondary-ctor4.check @@ -1,10 +1,10 @@ --- Error: tests/init/neg/secondary-ctor4.scala:54:14 ------------------------------------------------------------------- -54 | val c = new C(b, 5) // error +-- Warning: tests/init/warn/secondary-ctor4.scala:54:14 ---------------------------------------------------------------- +54 | val c = new C(b, 5) // warn | ^^^^^^^^^^^ | Problematic object instantiation: arg 1 is not transitively initialized (Hot). Calling trace: | ├── class D { [ secondary-ctor4.scala:52 ] | │ ^ - | └── val c = new C(b, 5) // error [ secondary-ctor4.scala:54 ] + | └── val c = new C(b, 5) // warn [ secondary-ctor4.scala:54 ] | ^^^^^^^^^^^ | | It leads to the following error during object initialization: @@ -21,15 +21,15 @@ | │ ^ | └── println(b.n) [ secondary-ctor4.scala:23 ] | ^^^ --- Error: tests/init/neg/secondary-ctor4.scala:42:4 -------------------------------------------------------------------- -42 | new A(new B(new D)) // error +-- Warning: tests/init/warn/secondary-ctor4.scala:42:4 ----------------------------------------------------------------- +42 | new A(new B(new D)) // warn | ^^^^^^^^^^^^^^^^^^^ |Problematic object instantiation: the outer M.this and arg 1 are not transitively initialized (Hot). Calling trace: |├── class N(d: D) extends M(d) { [ secondary-ctor4.scala:59 ] |│ ^ |├── def this(d: D) = { [ secondary-ctor4.scala:7 ] |│ ^ - |└── new A(new B(new D)) // error [ secondary-ctor4.scala:42 ] + |└── new A(new B(new D)) // warn [ secondary-ctor4.scala:42 ] | ^^^^^^^^^^^^^^^^^^^ | |It leads to the following error during object initialization: diff --git a/tests/init/neg/secondary-ctor4.scala b/tests/init/warn/secondary-ctor4.scala similarity index 90% rename from tests/init/neg/secondary-ctor4.scala rename to tests/init/warn/secondary-ctor4.scala index e80630002638..9c53034ee597 100644 --- a/tests/init/neg/secondary-ctor4.scala +++ b/tests/init/warn/secondary-ctor4.scala @@ -10,7 +10,7 @@ class M(x: Int) { class L1(x: Int) { val n: Int = 5 } class A(b: B, x: Int) { - println(d.n) + println(d.n) class L2(x: Int) { val n: Int = 5 } @@ -39,7 +39,7 @@ class M(x: Int) { val n: Int = 10 } - new A(new B(new D)) // error + new A(new B(new D)) // warn trait T { val m: Int = 10 @@ -51,7 +51,7 @@ class M(x: Int) { class D { val b = new B(this) - val c = new C(b, 5) // error + val c = new C(b, 5) // warn } } } diff --git a/tests/init/warn/simple1.scala b/tests/init/warn/simple1.scala new file mode 100644 index 000000000000..9f8ce2f5c487 --- /dev/null +++ b/tests/init/warn/simple1.scala @@ -0,0 +1,4 @@ +class Foo { + val len = name.size + val name: String = "Jack" // warn +} \ No newline at end of file diff --git a/tests/init/neg/simple2.scala b/tests/init/warn/simple2.scala similarity index 86% rename from tests/init/neg/simple2.scala rename to tests/init/warn/simple2.scala index 70a7f8407c6b..63fa64d5a113 100644 --- a/tests/init/neg/simple2.scala +++ b/tests/init/warn/simple2.scala @@ -4,7 +4,7 @@ class Box(x: Int) { List(3, 4, 5).map(_ * 2) - private var a = "hello" // error + private var a = "hello" // warn def f(m: Int) = m + a.size } diff --git a/tests/init/neg/simple3.scala b/tests/init/warn/simple3.scala similarity index 64% rename from tests/init/neg/simple3.scala rename to tests/init/warn/simple3.scala index 70de74b35bd4..245f982a807b 100644 --- a/tests/init/neg/simple3.scala +++ b/tests/init/warn/simple3.scala @@ -1,5 +1,5 @@ class Foo { val list = List(4, 6) val n = len + 5 - val len = list.size // error + val len = list.size // warn } diff --git a/tests/init/neg/simple5.scala b/tests/init/warn/simple5.scala similarity index 68% rename from tests/init/neg/simple5.scala rename to tests/init/warn/simple5.scala index 9c9d7d053830..bd9506076d26 100644 --- a/tests/init/neg/simple5.scala +++ b/tests/init/warn/simple5.scala @@ -6,7 +6,7 @@ class Foo { b - val name = "Jack" // error + val name = "Jack" // warn } class Bar { @@ -17,5 +17,5 @@ class Bar { b - val name = "Jack" // error + val name = "Jack" // warn } \ No newline at end of file diff --git a/tests/init/neg/soundness1.scala b/tests/init/warn/soundness1.scala similarity index 81% rename from tests/init/neg/soundness1.scala rename to tests/init/warn/soundness1.scala index d528b374f004..4d71c3e52747 100644 --- a/tests/init/neg/soundness1.scala +++ b/tests/init/warn/soundness1.scala @@ -20,10 +20,10 @@ object Test2: object Test3: class A(b: B) { println(b.a2) - val b2 = new B(this) // error + val b2 = new B(this) // warn } class B(a: A) { println(a.b2) - val a2 = new A(this) // error + val a2 = new A(this) // warn } diff --git a/tests/init/neg/soundness2.scala b/tests/init/warn/soundness2.scala similarity index 50% rename from tests/init/neg/soundness2.scala rename to tests/init/warn/soundness2.scala index 3d2821377111..6015ea46c3d7 100644 --- a/tests/init/neg/soundness2.scala +++ b/tests/init/warn/soundness2.scala @@ -1,4 +1,4 @@ class C(c: C) { val d = c.c2 - val c2 = new C(this) // error + val c2 = new C(this) // warn } diff --git a/tests/init/warn/soundness4.scala b/tests/init/warn/soundness4.scala new file mode 100644 index 000000000000..24060f2be083 --- /dev/null +++ b/tests/init/warn/soundness4.scala @@ -0,0 +1,3 @@ +class Foo { + val a : Foo = this.a.a // warn +} \ No newline at end of file diff --git a/tests/init/neg/soundness6.scala b/tests/init/warn/soundness6.scala similarity index 58% rename from tests/init/neg/soundness6.scala rename to tests/init/warn/soundness6.scala index 09d55dba292c..2893c3a4e301 100644 --- a/tests/init/neg/soundness6.scala +++ b/tests/init/warn/soundness6.scala @@ -1,5 +1,5 @@ class C(c: C) { println(c.n) - val c2 = new C(this) // error + val c2 = new C(this) // warn val n = 10 } diff --git a/tests/init/neg/structural.scala b/tests/init/warn/structural.scala similarity index 86% rename from tests/init/neg/structural.scala rename to tests/init/warn/structural.scala index 27b37a04bef7..bf20529a8007 100644 --- a/tests/init/neg/structural.scala +++ b/tests/init/warn/structural.scala @@ -8,5 +8,5 @@ class Test { n + x } - val n = m(23) // error + val n = m(23) // warn } diff --git a/tests/init/neg/super-resolution.scala b/tests/init/warn/super-resolution.scala similarity index 82% rename from tests/init/neg/super-resolution.scala rename to tests/init/warn/super-resolution.scala index d2674bc597e1..6fa295ed5187 100644 --- a/tests/init/neg/super-resolution.scala +++ b/tests/init/warn/super-resolution.scala @@ -16,8 +16,8 @@ trait N extends A with B: class C extends A with M with N: foo() - val a = 10 // error - val b = 20 // error - val m = 30 // error + val a = 10 // warn + val b = 20 // warn + val m = 30 // warn val n = 40 diff --git a/tests/init/neg/super-resolution2.scala b/tests/init/warn/super-resolution2.scala similarity index 84% rename from tests/init/neg/super-resolution2.scala rename to tests/init/warn/super-resolution2.scala index 283fb25a467d..5009e2f3aa64 100644 --- a/tests/init/neg/super-resolution2.scala +++ b/tests/init/warn/super-resolution2.scala @@ -15,6 +15,6 @@ class N extends A with B: new Inner - val m = 30 // error - val n = 40 // error + val m = 30 // warn + val n = 40 // warn val a = 50 diff --git a/tests/init/neg/super-resolution3.scala b/tests/init/warn/super-resolution3.scala similarity index 81% rename from tests/init/neg/super-resolution3.scala rename to tests/init/warn/super-resolution3.scala index 4d510ef22e61..e1b7a2ba3541 100644 --- a/tests/init/neg/super-resolution3.scala +++ b/tests/init/warn/super-resolution3.scala @@ -21,7 +21,7 @@ trait N extends A with B: class C extends A with M with N: new Inner() - val a = 10 // error - val b = 20 // error - val m = 30 // error - val n = 40 // error + val a = 10 // warn + val b = 20 // warn + val m = 30 // warn + val n = 40 // warn diff --git a/tests/init/neg/super.scala b/tests/init/warn/super.scala similarity index 87% rename from tests/init/neg/super.scala rename to tests/init/warn/super.scala index 5a8e72cce65f..9b0b88136f20 100644 --- a/tests/init/neg/super.scala +++ b/tests/init/warn/super.scala @@ -20,11 +20,11 @@ class Bar extends A, B, C: override def foo() = n * n - val n = 10 // error + val n = 10 // warn class Qux extends A, B, C: super.foo() override def foo() = n * n - val n = 10 // error + val n = 10 // warn diff --git a/tests/init/neg/t3273.scala b/tests/init/warn/t3273.scala similarity index 90% rename from tests/init/neg/t3273.scala rename to tests/init/warn/t3273.scala index af1df70c471e..c4b79a4dbfcc 100644 --- a/tests/init/neg/t3273.scala +++ b/tests/init/warn/t3273.scala @@ -1,8 +1,8 @@ import scala.language.implicitConversions class Test { - val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error - val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error + val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // warn + val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // warn def main(args: Array[String]): Unit = { val x1 = (num1 take 10).toList diff --git a/tests/init/neg/trait1.scala b/tests/init/warn/trait1.scala similarity index 79% rename from tests/init/neg/trait1.scala rename to tests/init/warn/trait1.scala index 48eae248fee7..d5c30569c4ee 100644 --- a/tests/init/neg/trait1.scala +++ b/tests/init/warn/trait1.scala @@ -3,7 +3,7 @@ abstract class A(x: Int) { foo() } -trait B(val y: Int) // error +trait B(val y: Int) // warn class C extends A(10) with B(20) { def foo(): Unit = println(y) diff --git a/tests/init/neg/trait2.scala b/tests/init/warn/trait2.scala similarity index 83% rename from tests/init/neg/trait2.scala rename to tests/init/warn/trait2.scala index 6011c259b73f..1b5bfded5730 100644 --- a/tests/init/neg/trait2.scala +++ b/tests/init/warn/trait2.scala @@ -3,7 +3,7 @@ abstract class A(x: Int) { foo() } -trait B(val y: Int) // error +trait B(val y: Int) // warn class D { class C extends A(10) with B(20) { diff --git a/tests/init/neg/trees.scala b/tests/init/warn/trees.scala similarity index 78% rename from tests/init/neg/trees.scala rename to tests/init/warn/trees.scala index 836f02e9c551..96ae170075c5 100644 --- a/tests/init/neg/trees.scala +++ b/tests/init/warn/trees.scala @@ -3,5 +3,5 @@ class Trees { class ValDef { counter += 1 } class EmptyValDef extends ValDef val theEmptyValDef = new EmptyValDef - private var counter = 0 // error + private var counter = 0 // warn } diff --git a/tests/init/neg/unsound1.scala b/tests/init/warn/unsound1.scala similarity index 80% rename from tests/init/neg/unsound1.scala rename to tests/init/warn/unsound1.scala index 3854504c8478..b017d1cd9f37 100644 --- a/tests/init/neg/unsound1.scala +++ b/tests/init/warn/unsound1.scala @@ -1,5 +1,5 @@ class A(m: Int) { - if (m > 0) println(foo(m - 1).a2.n) // error + if (m > 0) println(foo(m - 1).a2.n) // warn def foo(n: Int): B = if (n % 2 == 0) new B(new A(n - 1), foo(n - 1).a1) diff --git a/tests/init/neg/unsound2.scala b/tests/init/warn/unsound2.scala similarity index 88% rename from tests/init/neg/unsound2.scala rename to tests/init/warn/unsound2.scala index 5ae0c624c32e..d8b017f2c7db 100644 --- a/tests/init/neg/unsound2.scala +++ b/tests/init/warn/unsound2.scala @@ -2,7 +2,7 @@ case class A(x: Int) { def foo(y: Int): B = if (y > 10) then B(bar(y - 1), foo(y - 1).getN) else B(bar(y), 10) def bar(y: Int): A = if (y > 10) then A(y - 1) else this class B(a: A, b: Int) { - def getN: Int = a.n // error + def getN: Int = a.n // warn def getB: Int = b } println(foo(x).getB) diff --git a/tests/init/neg/unsound3.scala b/tests/init/warn/unsound3.scala similarity index 72% rename from tests/init/neg/unsound3.scala rename to tests/init/warn/unsound3.scala index 9ede5c7f97d0..021505cb9931 100644 --- a/tests/init/neg/unsound3.scala +++ b/tests/init/warn/unsound3.scala @@ -7,7 +7,7 @@ class C { def foo(): B = { x += 1 val newB = new B(this) - if (x < 12) then foo().getC().b else newB // error + if (x < 12) then foo().getC().b else newB // warn } val b = foo() } \ No newline at end of file diff --git a/tests/init/neg/unsound4.scala b/tests/init/warn/unsound4.scala similarity index 70% rename from tests/init/neg/unsound4.scala rename to tests/init/warn/unsound4.scala index 8a6e26fe8a6b..2b1a69723342 100644 --- a/tests/init/neg/unsound4.scala +++ b/tests/init/warn/unsound4.scala @@ -1,4 +1,4 @@ class A { def foo(x: Int): A = if (x < 5) then this else foo(x - 1).aAgain - val aAgain = foo(5) // error + val aAgain = foo(5) // warn } \ No newline at end of file