Skip to content

Commit c8b9bd4

Browse files
committed
Update check file
1 parent 1aecc3f commit c8b9bd4

17 files changed

+57
-48
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ object Errors:
8282

8383
case class AccessCold(field: Symbol, trace: Seq[Tree]) extends Error:
8484
def show(using Context): String =
85-
"Access field " + field.show + " on a value with a cold object." + stacktrace()
85+
"Access field " + field.show + " on a cold object." + stacktrace()
8686

8787
case class CallCold(meth: Symbol, trace: Seq[Tree]) extends Error:
8888
def show(using Context): String =
89-
"Call method " + meth.show + " on a value with an cold object." + stacktrace()
89+
"Call method " + meth.show + " on a cold object." + stacktrace()
9090

9191
case class CallUnknown(meth: Symbol, trace: Seq[Tree]) extends Error:
9292
def show(using Context): String =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ object Semantic:
12311231
/** Utility definition used for better error-reporting of argument errors */
12321232
case class ArgInfo(value: Value, trace: Trace):
12331233
def promote: Contextual[Unit] = withTrace(trace) {
1234-
value.promote("Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak. \nFound = " + value.show + ". ")
1234+
value.promote("Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.\nFound = " + value.show + ". ")
12351235
}
12361236

12371237
/** Evaluate an expression with the given value for `this` in a given class `klass`

tests/init/neg/closureLeak.check

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
22
11 | l.foreach(a => a.addX(this)) // error
33
| ^^^^^^^^^^^^^^^^^
4-
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak. Calling trace:
5-
| -> class Outer { [ closureLeak.scala:1 ]
6-
| ^
7-
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
8-
| ^^^^^^^^^^^^^^^^^
4+
| Cannot prove the argument is fully initialized. Only fully initialized 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+
| ^^^^^^^^^^^^^^^^^
910
|
10-
| Promoting the value to fully initialized failed due to the following problem:
11-
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
12-
| Non initialized field(s): value p. Calling trace:
13-
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
14-
| ^^^^
11+
| Promoting the value to fully initialized failed due to the following problem:
12+
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
13+
| Found = ThisRef[class Outer].
14+
| Non initialized field(s): value p. Calling trace:
15+
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
16+
| ^^^^

tests/init/neg/cycle-structure.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| ^^^^^^^
99
|
1010
| It leads to the following error during object initialization:
11-
| Access field on a value with an unknown initialization status. Calling trace:
11+
| Access field value x on a cold object. Calling trace:
1212
| -> case class B(a: A) { [ cycle-structure.scala:7 ]
1313
| ^
1414
| -> val x1 = a.x [ cycle-structure.scala:8 ]
@@ -23,7 +23,7 @@
2323
| ^^^^^^^
2424
|
2525
| It leads to the following error during object initialization:
26-
| Access field on a value with an unknown initialization status. Calling trace:
26+
| Access field value x on a 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
9 | compare() // error
33
| ^^^^^^^
44
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
5+
| Found = ThisRef[class B].
56
| Non initialized field(s): value result. Calling trace:
67
| -> class B extends A { [ default-this.scala:6 ]
78
| ^

tests/init/neg/i15363.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| ^^^^^^^^^^^
99
|
1010
| It leads to the following error during object initialization:
11-
| Access field on a value with an unknown initialization status. Calling trace:
11+
| Access field value m on a 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
3 | println(this) // error
33
| ^^^^
44
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
5+
| Found = ThisRef[class Sub].
56
| Non initialized field(s): value b. Calling trace:
67
| -> class Sub extends Sup: [ i15459.scala:5 ]
78
| ^

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
| ^^^^^^^^^^^^^^^
1313
|
1414
|Promoting the value to fully initialized failed due to the following problem:
15-
|Cannot prove that the field val a is fully initialized.
15+
|Cannot prove that the field value a is fully initialized. Found = Cold.

tests/init/neg/inlined-method.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
8 | scala.runtime.Scala3RunTime.assertFailed(message) // error
33
| ^^^^^^^
44
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
5+
| Found = ThisRef[class InlineError].
56
| Non initialized field(s): value v. Calling trace:
67
| -> class InlineError { [ inlined-method.scala:1 ]
78
| ^

tests/init/neg/inner-first.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
3 | println(this) // error
33
| ^^^^
44
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
5+
| Found = ThisRef[class B].
56
| Non initialized field(s): value n. Calling trace:
67
| -> class B: [ inner-first.scala:2 ]
78
| ^

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 on a value with an unknown initialization. Calling trace:
4+
| Call method method map on a 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: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
-- Error: tests/init/neg/promotion-loop.scala:16:10 --------------------------------------------------------------------
22
16 | println(b) // error
33
| ^
4-
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak. Calling trace:
5-
| -> class Test { test => [ promotion-loop.scala:1 ]
6-
| ^
7-
| -> println(b) // error [ promotion-loop.scala:16 ]
4+
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
5+
| Found = Warm[class B] { outer = ThisRef[class Test] }. Calling trace:
6+
| -> class Test { test => [ promotion-loop.scala:1 ]
87
| ^
8+
| -> println(b) // error [ promotion-loop.scala:16 ]
9+
| ^
910
|
10-
| Promoting the value to fully initialized failed due to the following problem:
11-
| Cannot prove that the field val outer is fully initialized.
12-
| Non initialized field(s): value n.
11+
| Promoting the value to fully initialized failed due to the following problem:
12+
| Cannot prove that the field value outer is fully initialized. Found = ThisRef[class Test].
13+
| Non initialized field(s): value n.

tests/init/neg/secondary-ctor4.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
| ^^^^^^^^^^^
99
|
1010
| It leads to the following error during object initialization:
11-
| Access field on a value with an unknown initialization status. Calling trace:
11+
| Access field value n on a 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 ]
@@ -33,7 +33,7 @@
3333
| ^^^^^^^^^^^^^^^^^^^
3434
|
3535
| It leads to the following error during object initialization:
36-
| Access field on a value with an unknown initialization status. Calling trace:
36+
| Access field value n on a cold object. Calling trace:
3737
| -> def this(b: B) = { [ secondary-ctor4.scala:17 ]
3838
| ^
3939
| -> Inner().foo() [ secondary-ctor4.scala:26 ]

tests/init/neg/t3273.check

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
-- Error: tests/init/neg/t3273.scala:4:42 ------------------------------------------------------------------------------
22
4 | val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error
33
| ^^^^^^^^^^^^^^^
4-
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak. Calling trace:
5-
| -> object Test { [ t3273.scala:3 ]
6-
| ^
7-
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
8-
| ^^^^^^^^^^^^^^^
4+
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
5+
| Found = Fun { this = ThisRef[object Test], owner = object Test }. Calling trace:
6+
| -> object Test { [ t3273.scala:3 ]
7+
| ^
8+
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
9+
| ^^^^^^^^^^^^^^^
910
|
10-
| Promoting the value to fully initialized failed due to the following problem:
11-
| Access non-initialized value num1. Calling trace:
12-
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
13-
| ^^^^
11+
| Promoting the value to fully initialized failed due to the following problem:
12+
| Access non-initialized value num1. Calling trace:
13+
| -> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
14+
| ^^^^
1415
-- Error: tests/init/neg/t3273.scala:5:61 ------------------------------------------------------------------------------
1516
5 | val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error
1617
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17-
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak. Calling trace:
18-
| -> object Test { [ t3273.scala:3 ]
19-
| ^
20-
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
21-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
| Cannot prove the argument is fully initialized. Only fully initialized values are safe to leak.
19+
| Found = Fun { this = ThisRef[object Test], owner = object Test }. Calling trace:
20+
| -> object Test { [ t3273.scala:3 ]
21+
| ^
22+
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2224
|
23-
| Promoting the value to fully initialized failed due to the following problem:
24-
| Access non-initialized value num2. Calling trace:
25-
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
26-
| ^^^^
25+
| Promoting the value to fully initialized failed due to the following problem:
26+
| Access non-initialized value num2. Calling trace:
27+
| -> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]
28+
| ^^^^

tests/init/neg/unsound1.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/unsound1.scala:2:35 ---------------------------------------------------------------------------
22
2 | if (m > 0) println(foo(m - 1).a2.n) // error
33
| ^^^^^^^^^^^^^^^
4-
| Access field on a value with an unknown initialization status. Calling trace:
4+
| Access field variable n on a cold object. Calling trace:
55
| -> class A(m: Int) { [ unsound1.scala:1 ]
66
| ^
77
| -> if (m > 0) println(foo(m - 1).a2.n) // error [ unsound1.scala:2 ]

tests/init/neg/unsound2.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/unsound2.scala:5:26 ---------------------------------------------------------------------------
22
5 | def getN: Int = a.n // error
33
| ^^^
4-
| Access field on a value with an unknown initialization status. Calling trace:
4+
| Access field value n on a cold object. Calling trace:
55
| -> case class A(x: Int) { [ unsound2.scala:1 ]
66
| ^
77
| -> println(foo(x).getB) [ unsound2.scala:8 ]

tests/init/neg/unsound3.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/unsound3.scala:10:38 --------------------------------------------------------------------------
22
10 | if (x < 12) then foo().getC().b else newB // error
33
| ^^^^^^^^^^^^^^
4-
| Access field on a value with an unknown initialization status. Calling trace:
4+
| Access field value b on a cold object. Calling trace:
55
| -> class C { [ unsound3.scala:5 ]
66
| ^
77
| -> val b = foo() [ unsound3.scala:12 ]

0 commit comments

Comments
 (0)