Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
Updating error message
  • Loading branch information
EnzeXing committed Jul 23, 2021
1 parent 9bea086 commit 25069bb
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/init/Errors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ object Errors {

/** Promote `this` under initialization to fully-initialized */
case class PromoteError(msg: String, source: Tree, trace: Seq[Tree]) extends Error {
def show(using Context): String = "Promote the value under initialization to fully-initialized. " + msg + "."
def show(using Context): String = "Cannot prove that the value is fully initialized. " + msg + "."
}

case class AccessCold(field: Symbol, source: Tree, trace: Seq[Tree]) extends Error {
Expand Down
5 changes: 0 additions & 5 deletions tests/init/neg/Desugar.check

This file was deleted.

5 changes: 0 additions & 5 deletions tests/init/neg/InteractiveDriver.check

This file was deleted.

6 changes: 3 additions & 3 deletions tests/init/neg/closureLeak.check
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
11 | l.foreach(a => a.addX(this)) // error
| ^^^^^^^^^^^^^^^^^
| Promoting the value to fully-initialized is unsafe. May only use initialized value as arguments
| Promoting the value to fully-initialized is unsafe. May only use initialized value as arguments
|
| The unsafe promotion may cause the following problem(s):
| The unsafe promotion may cause the following problem(s):
|
| 1. Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
| 1. Cannot prove that the value is fully initialized. May only use initialized value as arguments.
4 changes: 2 additions & 2 deletions tests/init/neg/cycle-structure.check
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Error: tests/init/neg/cycle-structure.scala:3:14 --------------------------------------------------------------------
3 | val x = B(this) // error
| ^^^^
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.
-- Error: tests/init/neg/cycle-structure.scala:9:14 --------------------------------------------------------------------
9 | val x = A(this) // error
| ^^^^
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.
4 changes: 2 additions & 2 deletions tests/init/neg/default-this.check
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------
9 | compare() // error
| ^^^^^^^
|Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]
| Cannot prove that the value is fully initialized. May only use initialized value as arguments. Calling trace:
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]
21 changes: 21 additions & 0 deletions tests/init/neg/inherit-non-hot.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This is a minimized test for the warning in Names.scala:174
object Foo {
abstract class A {
var b: B = null
def toB: B =
if b == null then b = new B(this) // error
b
}

class B(a: A) {
var aCopy: A = a
def getBAgain: B = aCopy.toB
}

class C extends A {
val bAgain = toB.getBAgain
}

val c = new C
assert(c.b == c.bAgain)
}
4 changes: 2 additions & 2 deletions tests/init/neg/leak-warm.check
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Error: tests/init/neg/leak-warm.scala:18:26 -------------------------------------------------------------------------
18 | val l: List[A] = List(c, d) // error // error
| ^
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.
-- Error: tests/init/neg/leak-warm.scala:18:29 -------------------------------------------------------------------------
18 | val l: List[A] = List(c, d) // error // error
| ^
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.
16 changes: 8 additions & 8 deletions tests/init/neg/local-warm4.check
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- Error: tests/init/neg/local-warm4.scala:18:20 -----------------------------------------------------------------------
18 | a = newA // error
| ^^^^
|Promote the value under initialization to fully-initialized. May only assign fully initialized value. Calling trace:
| -> val a = new A(5) [ local-warm4.scala:26 ]
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
| -> val b = new B(y) [ local-warm4.scala:10 ]
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
| -> increment() [ local-warm4.scala:9 ]
| -> updateA() [ local-warm4.scala:21 ]
| Cannot prove that the value is fully initialized. May only assign fully initialized value. Calling trace:
| -> val a = new A(5) [ local-warm4.scala:26 ]
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
| -> val b = new B(y) [ local-warm4.scala:10 ]
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
| -> increment() [ local-warm4.scala:9 ]
| -> updateA() [ local-warm4.scala:21 ]
4 changes: 0 additions & 4 deletions tests/init/neg/local-warm4.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ object localWarm {
}
val a = new A(5)
}




2 changes: 1 addition & 1 deletion tests/init/neg/promotion-loop.check
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
|
|The unsafe promotion may cause the following problem(s):
|
|1. Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
|1. Cannot prove that the value is fully initialized. May only use initialized value as arguments. Calling trace:
| -> val outer = test [ promotion-loop.scala:12 ]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ case class C[-T >: Int] (lhs: Int, rhs: Tree[T]) extends A {
}

object DesugarError {
val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x} // error
val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x}
}


File renamed without changes.

0 comments on commit 25069bb

Please sign in to comment.