Skip to content

Commit 6f22980

Browse files
committed
Add parentheses to make warnings more clear
1 parent 4cc629e commit 6f22980

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ 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 + "\" where initialization checking started"
67+
"the original object of type (" + klass.show + ") where initialization checking started"
6868
case Warm(klass, outer, ctor, args) =>
6969
val argsText = if args.nonEmpty then ", args = " + args.map(_.show).mkString("(", ", ", ")") else ""
70-
"an initialized (Warm) object of type " + klass.show + "{ outer = " + outer.show + argsText + " }"
70+
"an initialized (Warm) object of type (" + klass.show + ") { outer = " + outer.show + argsText + " }"
7171
case Fun(expr, thisV, klass) =>
72-
"a function where \"this\" is " + thisV.show + " and the function owner is an object of type " + klass.show
72+
"a function where \"this\" is (" + thisV.show + ") and the function owner is an object of type (" + klass.show + ")"
7373
case RefSet(values) =>
7474
values.map(_.show).mkString("Set { ", ", ", " }")
7575
case Hot =>

tests/init/neg/closureLeak.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
22
11 | l.foreach(a => a.addX(this)) // error
33
| ^^^^^^^^^^^^^^^^^
4-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is the original object of type "class Outer" where initialization checking started and the function owner is an object of type class Outer. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is (the original object of type (class Outer) where initialization checking started) and the function owner is an object of type (class Outer). Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
55
|-> class Outer { [ closureLeak.scala:1 ]
66
| ^
77
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
88
| ^^^^^^^^^^^^^^^^^
99
|
1010
|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" where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
11+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class Outer) where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
1212
|Non initialized field(s): value p. Promotion trace:
1313
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ]
1414
| ^^^^

tests/init/neg/default-this.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------
22
9 | compare() // error
33
| ^^^^^^^
4-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class B" where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class B) where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
55
|Non initialized field(s): value result. Calling trace:
66
|-> class B extends A { [ default-this.scala:6 ]
77
| ^

tests/init/neg/i15459.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/i15459.scala:3:10 -----------------------------------------------------------------------------
22
3 | println(this) // error
33
| ^^^^
4-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class Sub" where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class Sub) where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
55
|Non initialized field(s): value b. Calling trace:
66
|-> class Sub extends Sup: [ i15459.scala:5 ]
77
| ^

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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 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:
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:
55
|-> class C extends A { [ inherit-non-hot.scala:15 ]
66
| ^
77
|-> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ]

tests/init/neg/inlined-method.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/inlined-method.scala:8:45 ---------------------------------------------------------------------
22
8 | scala.runtime.Scala3RunTime.assertFailed(message) // error
33
| ^^^^^^^
4-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class InlineError" where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class InlineError) where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
55
|Non initialized field(s): value v. Calling trace:
66
|-> class InlineError { [ inlined-method.scala:1 ]
77
| ^

tests/init/neg/inner-first.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/inner-first.scala:3:12 ------------------------------------------------------------------------
22
3 | println(this) // error
33
| ^^^^
4-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type "class B" where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be the original object of type (class B) where initialization checking started. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.
55
|Non initialized field(s): value n. Calling trace:
66
|-> class B: [ inner-first.scala:2 ]
77
| ^

tests/init/neg/promotion-loop.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- Error: tests/init/neg/promotion-loop.scala:16:10 --------------------------------------------------------------------
22
16 | println(b) // error
33
| ^
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" where initialization checking started }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
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) where initialization checking started }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
55
|-> class Test { test => [ promotion-loop.scala:1 ]
66
| ^
77
|-> println(b) // error [ promotion-loop.scala:16 ]
88
| ^
99
|
1010
|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" where initialization checking started.
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) where initialization checking started.
1212
|Non initialized field(s): value n. Promotion trace:
1313
|-> val outer = test [ promotion-loop.scala:12 ]
1414
| ^^^^^^^^^^^^^^^^

tests/init/neg/promotion-segment3.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/promotion-segment3.scala:9:6 ------------------------------------------------------------------
22
9 | bar(new B) // error
33
| ^^^^^
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" where initialization checking started }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
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) where initialization checking started }. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
55
|-> class A: [ promotion-segment3.scala:2 ]
66
| ^
77
|-> bar(new B) // error [ promotion-segment3.scala:9 ]

tests/init/neg/t3273.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/init/neg/t3273.scala:4:42 ------------------------------------------------------------------------------
22
4 | val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error
33
| ^^^^^^^^^^^^^^^
4-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is the original object of type "object Test" where initialization checking started and the function owner is an object of type object Test. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
4+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is (the original object of type (object Test) where initialization checking started) and the function owner is an object of type (object Test). Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
55
|-> object Test { [ t3273.scala:3 ]
66
| ^
77
|-> val num1: LazyList[Int] = 1 #:: num1.map(_ + 1) // error [ t3273.scala:4 ]
@@ -14,7 +14,7 @@
1414
-- Error: tests/init/neg/t3273.scala:5:61 ------------------------------------------------------------------------------
1515
5 | val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17-
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is the original object of type "object Test" where initialization checking started and the function owner is an object of type object Test. Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
17+
|Could not verify that the method argument is transitively initialized (Hot). It was found to be a function where "this" is (the original object of type (object Test) where initialization checking started) and the function owner is an object of type (object Test). Only transitively initialized arguments may be passed to methods outside the analyzed initialization region. Calling trace:
1818
|-> object Test { [ t3273.scala:3 ]
1919
| ^
2020
|-> val num2: LazyList[Int] = 1 #:: num2.iterator.map(_ + 1).to(LazyList) // error [ t3273.scala:5 ]

0 commit comments

Comments
 (0)