Skip to content

Commit 603822e

Browse files
committed
Make warning message more accurate.
1 parent 36298a2 commit 603822e

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ object Semantic:
11481148

11491149
extension (arg: ArgInfo)
11501150
def promote: Contextual[Unit] = withTrace(arg.trace) {
1151-
arg.value.promote("Could not verify that the method argument is transitively initialized (Hot). It was found to be " + arg.value.show + ". Only transitively initialized arguments may be passed to methods outside the analyzed initialization region.")
1151+
arg.value.promote("Could not verify that the method argument is transitively initialized (Hot). It was found to be " + arg.value.show + ". Only transitively initialized arguments may be passed to methods (except constructors).")
11521152
}
11531153

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

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 (except constructors). 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 (except constructors).
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 (except constructors).
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 (except constructors).
55
|Non initialized field(s): value b. Calling trace:
66
|-> class Sub extends Sup: [ i15459.scala:5 ]
77
| ^

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 (except constructors).
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 (except constructors).
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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 a non-transitively 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 a non-transitively 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 (except constructors). Calling trace:
55
|-> class Test { test => [ promotion-loop.scala:1 ]
66
| ^
77
|-> println(b) // error [ promotion-loop.scala:16 ]

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 a non-transitively 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 a non-transitively 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 (except constructors). 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 (except constructors). 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 (except constructors). 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)