Skip to content

Commit 585409a

Browse files
committed
Update check files, minor wording changes to error messages
1 parent da1b028 commit 585409a

17 files changed

+108
-118
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ object Semantic:
6464
sealed abstract class Value:
6565
def show(using Context): String = this match
6666
case ThisRef(klass) =>
67-
"the original object of type " + klass.show + " that started this trace"
67+
"the original object of type \"" + klass.show + "\" that started this trace"
6868
case Warm(klass, outer, ctor, args) =>
6969
val argsText = if args.nonEmpty then ", args = " + args.map(_.show).mkString("(", ", ", ")") else ""
7070
"an initialized (Warm) object of type " + klass.show + "{ outer = " + outer.show + argsText + " }"
@@ -472,7 +472,7 @@ object Semantic:
472472
def widenArg: Contextual[Value] =
473473
a match
474474
case _: Ref | _: Fun =>
475-
val hasError = Reporter.hasErrors { a.promote("Argument cannot be promoted to transitively initialized (Hot)") }
475+
val hasError = Reporter.hasErrors { a.promote("Argument cannot be proven to be transitively initialized (Hot)") }
476476
if hasError then Cold else Hot
477477

478478
case RefSet(refs) =>
@@ -996,7 +996,7 @@ object Semantic:
996996
eval(body, thisV, klass)
997997
}
998998
given Trace = Trace.empty.add(body)
999-
res.promote("Only transitively initialized (Hot) values can be returned by functions. The function " + fun.show + " returned " + res.show + ".")
999+
res.promote("Only transitively initialized (Hot) values can be returned by functions. The function " + fun.show + " returns " + res.show + ".")
10001000
}
10011001
if errors.nonEmpty then
10021002
reporter.report(UnsafePromotion(msg, errors.head)(trace))
@@ -1040,7 +1040,7 @@ object Semantic:
10401040
//
10411041
// This invariant holds because of the Scala/Java/JVM restriction that we cannot use `this` in super constructor calls.
10421042
if subClassSegmentHot && !isHotSegment then
1043-
report.error("[Internal error] Expect current segment to be transitively initialized (hot) in promotion, current klass = " + klass.show +
1043+
report.error("[Internal error] Expect current segment to be transitively initialized (Hot) in promotion, current klass = " + klass.show +
10441044
", subclass = " + subClass.show + Trace.show, Trace.position)
10451045

10461046
// If the outer and parameters of a class are all hot, then accessing fields and methods of the current

tests/init/neg/closureLeak.check

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
22
11 | l.foreach(a => a.addX(this)) // error
33
| ^^^^^^^^^^^^^^^^^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = Fun { this = ThisRef[class Outer], owner = class Outer }. Calling trace:
6-
| -> class Outer { [ closureLeak.scala:1 ]
7-
| ^
8-
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
9-
| ^^^^^^^^^^^^^^^^^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function { this = the original object of type "class Outer" that started this trace, owner = class Outer }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
5+
|-> class Outer { [ closureLeak.scala:1 ]
6+
| ^
7+
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
8+
| ^^^^^^^^^^^^^^^^^
109
|
11-
| Promoting the value to hot (transitively initialized) failed due to the following problem:
12-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
13-
| Found = ThisRef[class Outer].
14-
| Non initialized field(s): value p. Promotion trace:
15-
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
16-
| ^^^^
10+
|Promoting the value to transitively initialized (Hot) failed due to the following problem:
11+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class Outer" that started this trace. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
12+
|Non initialized field(s): value p. Promotion trace:
13+
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
14+
| ^^^^

tests/init/neg/cycle-structure.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
-- Error: tests/init/neg/cycle-structure.scala:3:13 --------------------------------------------------------------------
22
3 | val x = B(this) // error
33
| ^^^^^^^
4-
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
4+
| Problematic object instantiation: arg 1 is not transitively initialized (Hot). Calling trace:
55
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
66
| ^
77
| -> val x = B(this) // error [ cycle-structure.scala:3 ]
88
| ^^^^^^^
99
|
1010
| It leads to the following error during object initialization:
11-
| Access field value x on a cold object. Calling trace:
11+
| Access field value x on an uninitialized (Cold) object. Calling trace:
1212
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
1313
| ^
1414
| -> val x1 = a.x [ cycle-structure.scala:8 ]
1515
| ^^^
1616
-- Error: tests/init/neg/cycle-structure.scala:9:13 --------------------------------------------------------------------
1717
9 | val x = A(this) // error
1818
| ^^^^^^^
19-
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
19+
| Problematic object instantiation: arg 1 is not transitively initialized (Hot). Calling trace:
2020
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
2121
| ^
2222
| -> val x = A(this) // error [ cycle-structure.scala:9 ]
2323
| ^^^^^^^
2424
|
2525
| It leads to the following error during object initialization:
26-
| Access field value x on a cold object. Calling trace:
26+
| Access field value x on an uninitialized (Cold) object. Calling trace:
2727
| -> case class A(b: B) { [ cycle-structure.scala:1 ]
2828
| ^
2929
| -> val x1 = b.x [ cycle-structure.scala:2 ]

tests/init/neg/default-this.check

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------
22
9 | compare() // error
33
| ^^^^^^^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = ThisRef[class B].
6-
| Non initialized field(s): value result. Calling trace:
7-
| -> class B extends A { [ default-this.scala:6 ]
8-
| ^
9-
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]
10-
| ^^^^^^^^^^^^^^^^^^^^
11-
| -> def updateThenCompare(c: Int): Boolean = { [ default-this.scala:7 ]
12-
| ^
13-
| -> compare() // error [ default-this.scala:9 ]
14-
| ^^^^^^^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class B" that started this trace. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
5+
|Non initialized field(s): value result. Calling trace:
6+
|-> class B extends A { [ default-this.scala:6 ]
7+
| ^
8+
|-> val result = updateThenCompare(5) [ default-this.scala:11 ]
9+
| ^^^^^^^^^^^^^^^^^^^^
10+
|-> def updateThenCompare(c: Int): Boolean = { [ default-this.scala:7 ]
11+
| ^
12+
|-> compare() // error [ default-this.scala:9 ]
13+
| ^^^^^^^

tests/init/neg/i15363.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- Error: tests/init/neg/i15363.scala:3:10 -----------------------------------------------------------------------------
22
3 | val b = new B(this) // error
33
| ^^^^^^^^^^^
4-
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
4+
| Problematic object instantiation: arg 1 is not transitively initialized (Hot). Calling trace:
55
| -> class A: [ i15363.scala:1 ]
66
| ^
77
| -> val b = new B(this) // error [ i15363.scala:3 ]
88
| ^^^^^^^^^^^
99
|
1010
| It leads to the following error during object initialization:
11-
| Access field value m on a cold object. Calling trace:
11+
| Access field value m on an uninitialized (Cold) object. Calling trace:
1212
| -> class B(a: A): [ i15363.scala:7 ]
1313
| ^
1414
| -> val x = a.m [ i15363.scala:8 ]

tests/init/neg/i15459.check

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
-- Error: tests/init/neg/i15459.scala:3:10 -----------------------------------------------------------------------------
22
3 | println(this) // error
33
| ^^^^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = ThisRef[class Sub].
6-
| Non initialized field(s): value b. Calling trace:
7-
| -> class Sub extends Sup: [ i15459.scala:5 ]
8-
| ^
9-
| -> class Sup: [ i15459.scala:1 ]
10-
| ^
11-
| -> println(this) // error [ i15459.scala:3 ]
12-
| ^^^^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class Sub" that started this trace. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
5+
|Non initialized field(s): value b. Calling trace:
6+
|-> class Sub extends Sup: [ i15459.scala:5 ]
7+
| ^
8+
|-> class Sup: [ i15459.scala:1 ]
9+
| ^
10+
|-> println(this) // error [ i15459.scala:3 ]
11+
| ^^^^

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
-- Error: tests/init/neg/inherit-non-hot.scala:6:32 --------------------------------------------------------------------
22
6 | if b == null then b = new B(this) // error
33
| ^^^^^^^^^^^^^^^
4-
| The RHS of reassignment must be hot. Found = Warm[class B] { outer = Hot, args = (Cold) }. Calling trace:
5-
| -> class C extends A { [ inherit-non-hot.scala:15 ]
6-
| ^
7-
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]
8-
| ^^^
9-
| -> def toB: B = [ inherit-non-hot.scala:5 ]
10-
| ^
11-
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ]
12-
| ^^^^^^^^^^^^^^^
4+
|The RHS of reassignment must be transitively initialized (Hot). It was found to be an initialized (Warm) object of type class B{ outer = a transitively initialized (Hot) object, args = (an uninitialized (Cold) object) }. Calling trace:
5+
|-> class C extends A { [ inherit-non-hot.scala:15 ]
6+
| ^
7+
|-> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]
8+
| ^^^
9+
|-> def toB: B = [ inherit-non-hot.scala:5 ]
10+
| ^
11+
|-> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ]
12+
| ^^^^^^^^^^^^^^^
1313
|
14-
| Promoting the value to hot (transitively initialized) failed due to the following problem:
15-
| Cannot prove that the field value a is hot. Found = Cold. Promotion trace:
16-
| -> class B(a: A) { [ inherit-non-hot.scala:10 ]
17-
| ^^^^
14+
|Promoting the value to transitively initialized (Hot) failed due to the following problem:
15+
|Could not verify that the field value a is transitively initialized (Hot). It was found to be an uninitialized (Cold) object. Promotion trace:
16+
|-> class B(a: A) { [ inherit-non-hot.scala:10 ]
17+
| ^^^^

tests/init/neg/inlined-method.check

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
-- Error: tests/init/neg/inlined-method.scala:8:45 ---------------------------------------------------------------------
22
8 | scala.runtime.Scala3RunTime.assertFailed(message) // error
33
| ^^^^^^^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = ThisRef[class InlineError].
6-
| Non initialized field(s): value v. Calling trace:
7-
| -> class InlineError { [ inlined-method.scala:1 ]
8-
| ^
9-
| -> Assertion.failAssert(this) [ inlined-method.scala:2 ]
10-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
11-
| -> scala.runtime.Scala3RunTime.assertFailed(message) // error [ inlined-method.scala:8 ]
12-
| ^^^^^^^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class InlineError" that started this trace. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
5+
|Non initialized field(s): value v. Calling trace:
6+
|-> class InlineError { [ inlined-method.scala:1 ]
7+
| ^
8+
|-> Assertion.failAssert(this) [ inlined-method.scala:2 ]
9+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
|-> scala.runtime.Scala3RunTime.assertFailed(message) // error [ inlined-method.scala:8 ]
11+
| ^^^^^^^

tests/init/neg/inner-first.check

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
-- Error: tests/init/neg/inner-first.scala:3:12 ------------------------------------------------------------------------
22
3 | println(this) // error
33
| ^^^^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = ThisRef[class B].
6-
| Non initialized field(s): value n. Calling trace:
7-
| -> class B: [ inner-first.scala:2 ]
8-
| ^
9-
| -> println(this) // error [ inner-first.scala:3 ]
10-
| ^^^^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class B" that started this trace. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
5+
|Non initialized field(s): value n. Calling trace:
6+
|-> class B: [ inner-first.scala:2 ]
7+
| ^
8+
|-> println(this) // error [ inner-first.scala:3 ]
9+
| ^^^^

tests/init/neg/leak-warm.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/leak-warm.scala:19:18 -------------------------------------------------------------------------
22
19 | val l2 = l.map(_.m()) // error
33
| ^^^^^^^^^^^^
4-
| Call method method map on a cold object. Calling trace:
4+
| Call method method map on an uninitialized (Cold) object. Calling trace:
55
| -> object leakWarm { [ leak-warm.scala:1 ]
66
| ^
77
| -> val l2 = l.map(_.m()) // error [ leak-warm.scala:19 ]

tests/init/neg/promotion-loop.check

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
-- Error: tests/init/neg/promotion-loop.scala:16:10 --------------------------------------------------------------------
22
16 | println(b) // error
33
| ^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = Warm[class B] { outer = ThisRef[class Test] }. Calling trace:
6-
| -> class Test { test => [ promotion-loop.scala:1 ]
7-
| ^
8-
| -> println(b) // error [ promotion-loop.scala:16 ]
9-
| ^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be an initialized (Warm) object of type class B{ outer = the original object of type "class Test" that started this trace }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
5+
|-> class Test { test => [ promotion-loop.scala:1 ]
6+
| ^
7+
|-> println(b) // error [ promotion-loop.scala:16 ]
8+
| ^
109
|
11-
| Promoting the value to hot (transitively initialized) failed due to the following problem:
12-
| Cannot prove that the field value outer is hot. Found = ThisRef[class Test].
13-
| Non initialized field(s): value n. Promotion trace:
14-
| -> val outer = test [ promotion-loop.scala:12 ]
15-
| ^^^^^^^^^^^^^^^^
10+
|Promoting the value to transitively initialized (Hot) failed due to the following problem:
11+
|Could not verify that the field value outer is transitively initialized (Hot). It was found to be the original object of type "class Test" that started this trace.
12+
|Non initialized field(s): value n. Promotion trace:
13+
|-> val outer = test [ promotion-loop.scala:12 ]
14+
| ^^^^^^^^^^^^^^^^
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
-- Error: tests/init/neg/promotion-segment3.scala:9:6 ------------------------------------------------------------------
22
9 | bar(new B) // error
33
| ^^^^^
4-
| Cannot prove the method argument is hot. Only hot values are safe to leak.
5-
| Found = Warm[class B] { outer = ThisRef[class A] }. Calling trace:
6-
| -> class A: [ promotion-segment3.scala:2 ]
7-
| ^
8-
| -> bar(new B) // error [ promotion-segment3.scala:9 ]
9-
| ^^^^^
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be an initialized (Warm) object of type class B{ outer = the original object of type "class A" that started this trace }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
5+
|-> class A: [ promotion-segment3.scala:2 ]
6+
| ^
7+
|-> bar(new B) // error [ promotion-segment3.scala:9 ]
8+
| ^^^^^
109
|
11-
| Promoting the value to hot (transitively initialized) failed due to the following problem:
12-
| Promotion cancelled as the value contains inner class C.
10+
|Promoting the value to transitively initialized (Hot) failed due to the following problem:
11+
|Promotion cancelled as the value contains inner class C.

tests/init/neg/secondary-ctor4.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- Error: tests/init/neg/secondary-ctor4.scala:54:14 -------------------------------------------------------------------
22
54 | val c = new C(b, 5) // error
33
| ^^^^^^^^^^^
4-
| Problematic object instantiation: arg 1 is not hot (transitively initialized). Calling trace:
4+
| Problematic object instantiation: arg 1 is not transitively initialized (Hot). Calling trace:
55
| -> class D { [ secondary-ctor4.scala:52 ]
66
| ^
77
| -> val c = new C(b, 5) // error [ secondary-ctor4.scala:54 ]
88
| ^^^^^^^^^^^
99
|
1010
| It leads to the following error during object initialization:
11-
| Access field value n on a cold object. Calling trace:
11+
| Access field value n on an uninitialized (Cold) object. Calling trace:
1212
| -> def this(b: B, x: Int) = this(b) [ secondary-ctor4.scala:49 ]
1313
| ^^^^^^^
1414
| -> class C(b: B) extends A(b) with T { [ secondary-ctor4.scala:48 ]
@@ -24,7 +24,7 @@
2424
-- Error: tests/init/neg/secondary-ctor4.scala:42:4 --------------------------------------------------------------------
2525
42 | new A(new B(new D)) // error
2626
| ^^^^^^^^^^^^^^^^^^^
27-
|Problematic object instantiation: the outer M.this and arg 1 are not hot (transitively initialized). Calling trace:
27+
|Problematic object instantiation: the outer M.this and arg 1 are not transitively initialized (Hot). Calling trace:
2828
|-> class N(d: D) extends M(d) { [ secondary-ctor4.scala:59 ]
2929
| ^
3030
|-> def this(d: D) = { [ secondary-ctor4.scala:7 ]
@@ -33,7 +33,7 @@
3333
| ^^^^^^^^^^^^^^^^^^^
3434
|
3535
|It leads to the following error during object initialization:
36-
|Access field value n on a cold object. Calling trace:
36+
|Access field value n on an uninitialized (Cold) object. Calling trace:
3737
|-> def this(b: B) = { [ secondary-ctor4.scala:17 ]
3838
| ^
3939
|-> Inner().foo() [ secondary-ctor4.scala:26 ]

0 commit comments

Comments
 (0)