Skip to content

Commit 25069bb

Browse files
committed
Update tests
Updating error message
1 parent 9bea086 commit 25069bb

13 files changed

+41
-34
lines changed

compiler/src/dotty/tools/dotc/transform/init/Errors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ object Errors {
6969

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

7575
case class AccessCold(field: Symbol, source: Tree, trace: Seq[Tree]) extends Error {

tests/init/neg/Desugar.check

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/init/neg/InteractiveDriver.check

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/init/neg/closureLeak.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
22
11 | l.foreach(a => a.addX(this)) // error
33
| ^^^^^^^^^^^^^^^^^
4-
| Promoting the value to fully-initialized is unsafe. May only use initialized value as arguments
4+
| Promoting the value to fully-initialized is unsafe. May only use initialized value as arguments
55
|
6-
| The unsafe promotion may cause the following problem(s):
6+
| The unsafe promotion may cause the following problem(s):
77
|
8-
| 1. Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
8+
| 1. Cannot prove that the value is fully initialized. May only use initialized value as arguments.

tests/init/neg/cycle-structure.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- Error: tests/init/neg/cycle-structure.scala:3:14 --------------------------------------------------------------------
22
3 | val x = B(this) // error
33
| ^^^^
4-
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
4+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.
55
-- Error: tests/init/neg/cycle-structure.scala:9:14 --------------------------------------------------------------------
66
9 | val x = A(this) // error
77
| ^^^^
8-
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
8+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments.

tests/init/neg/default-this.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------
22
9 | compare() // error
33
| ^^^^^^^
4-
|Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
5-
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]
4+
| Cannot prove that the value is fully initialized. May only use initialized value as arguments. Calling trace:
5+
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]

tests/init/neg/inherit-non-hot.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This is a minimized test for the warning in Names.scala:174
2+
object Foo {
3+
abstract class A {
4+
var b: B = null
5+
def toB: B =
6+
if b == null then b = new B(this) // error
7+
b
8+
}
9+
10+
class B(a: A) {
11+
var aCopy: A = a
12+
def getBAgain: B = aCopy.toB
13+
}
14+
15+
class C extends A {
16+
val bAgain = toB.getBAgain
17+
}
18+
19+
val c = new C
20+
assert(c.b == c.bAgain)
21+
}

tests/init/neg/leak-warm.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- Error: tests/init/neg/leak-warm.scala:18:26 -------------------------------------------------------------------------
22
18 | val l: List[A] = List(c, d) // error // error
33
| ^
4-
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
4+
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.
55
-- Error: tests/init/neg/leak-warm.scala:18:29 -------------------------------------------------------------------------
66
18 | val l: List[A] = List(c, d) // error // error
77
| ^
8-
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
8+
| Cannot prove that the value is fully initialized. May only use initialized value as method arguments.

tests/init/neg/local-warm4.check

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
-- Error: tests/init/neg/local-warm4.scala:18:20 -----------------------------------------------------------------------
22
18 | a = newA // error
33
| ^^^^
4-
|Promote the value under initialization to fully-initialized. May only assign fully initialized value. Calling trace:
5-
| -> val a = new A(5) [ local-warm4.scala:26 ]
6-
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
7-
| -> val b = new B(y) [ local-warm4.scala:10 ]
8-
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
9-
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
10-
| -> increment() [ local-warm4.scala:9 ]
11-
| -> updateA() [ local-warm4.scala:21 ]
4+
| Cannot prove that the value is fully initialized. May only assign fully initialized value. Calling trace:
5+
| -> val a = new A(5) [ local-warm4.scala:26 ]
6+
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
7+
| -> val b = new B(y) [ local-warm4.scala:10 ]
8+
| -> class B(x: Int) extends A(x) { [ local-warm4.scala:13 ]
9+
| -> class A(x: Int) extends Foo(x) { [ local-warm4.scala:6 ]
10+
| -> increment() [ local-warm4.scala:9 ]
11+
| -> updateA() [ local-warm4.scala:21 ]

tests/init/neg/local-warm4.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,3 @@ object localWarm {
2525
}
2626
val a = new A(5)
2727
}
28-
29-
30-
31-

tests/init/neg/promotion-loop.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
|
66
|The unsafe promotion may cause the following problem(s):
77
|
8-
|1. Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
8+
|1. Cannot prove that the value is fully initialized. May only use initialized value as arguments. Calling trace:
99
| -> val outer = test [ promotion-loop.scala:12 ]

tests/init/neg/Desugar.scala renamed to tests/init/pos/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ case class C[-T >: Int] (lhs: Int, rhs: Tree[T]) extends A {
99
}
1010

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

1515

0 commit comments

Comments
 (0)