-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reword error messages in initialization checker to be more user frien…
…dly. (#17030) Rewords some warning messages produced by the -Ysafe-init flag so that they are better understood by the user. Addresses Issue #15836
- Loading branch information
Showing
18 changed files
with
128 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
-- Error: tests/init/neg/closureLeak.scala:11:14 ----------------------------------------------------------------------- | ||
11 | l.foreach(a => a.addX(this)) // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = Fun { this = ThisRef[class Outer], owner = class Outer }. Calling trace: | ||
| -> class Outer { [ closureLeak.scala:1 ] | ||
| ^ | ||
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^ | ||
|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). Only transitively initialized arguments may be passed to methods (except constructors). Calling trace: | ||
|-> class Outer { [ closureLeak.scala:1 ] | ||
| ^ | ||
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
| Promoting the value to hot (transitively initialized) failed due to the following problem: | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class Outer]. | ||
| Non initialized field(s): value p. Promotion trace: | ||
| -> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^ | ||
|Promoting the value to transitively initialized (Hot) failed due to the following problem: | ||
|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). | ||
|Non initialized field(s): value p. Promotion trace: | ||
|-> l.foreach(a => a.addX(this)) // error [ closureLeak.scala:11 ] | ||
| ^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------ | ||
9 | compare() // error | ||
| ^^^^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class B]. | ||
| Non initialized field(s): value result. Calling trace: | ||
| -> class B extends A { [ default-this.scala:6 ] | ||
| ^ | ||
| -> val result = updateThenCompare(5) [ default-this.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| -> def updateThenCompare(c: Int): Boolean = { [ default-this.scala:7 ] | ||
| ^ | ||
| -> compare() // error [ default-this.scala:9 ] | ||
| ^^^^^^^ | ||
|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). | ||
|Non initialized field(s): value result. Calling trace: | ||
|-> class B extends A { [ default-this.scala:6 ] | ||
| ^ | ||
|-> val result = updateThenCompare(5) [ default-this.scala:11 ] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|-> def updateThenCompare(c: Int): Boolean = { [ default-this.scala:7 ] | ||
| ^ | ||
|-> compare() // error [ default-this.scala:9 ] | ||
| ^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
-- Error: tests/init/neg/i15459.scala:3:10 ----------------------------------------------------------------------------- | ||
3 | println(this) // error | ||
| ^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class Sub]. | ||
| Non initialized field(s): value b. Calling trace: | ||
| -> class Sub extends Sup: [ i15459.scala:5 ] | ||
| ^ | ||
| -> class Sup: [ i15459.scala:1 ] | ||
| ^ | ||
| -> println(this) // error [ i15459.scala:3 ] | ||
| ^^^^ | ||
|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). | ||
|Non initialized field(s): value b. Calling trace: | ||
|-> class Sub extends Sup: [ i15459.scala:5 ] | ||
| ^ | ||
|-> class Sup: [ i15459.scala:1 ] | ||
| ^ | ||
|-> println(this) // error [ i15459.scala:3 ] | ||
| ^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
-- Error: tests/init/neg/inherit-non-hot.scala:6:32 -------------------------------------------------------------------- | ||
6 | if b == null then b = new B(this) // error | ||
| ^^^^^^^^^^^^^^^ | ||
| The RHS of reassignment must be hot. Found = Warm[class B] { outer = Hot, args = (Cold) }. Calling trace: | ||
| -> class C extends A { [ inherit-non-hot.scala:15 ] | ||
| ^ | ||
| -> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ] | ||
| ^^^ | ||
| -> def toB: B = [ inherit-non-hot.scala:5 ] | ||
| ^ | ||
| -> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ] | ||
| ^^^^^^^^^^^^^^^ | ||
|The RHS of reassignment must be transitively initialized (Hot). It was found to be a non-transitively initialized (Warm) object of type (class B) { outer = a transitively initialized (Hot) object, args = (an uninitialized (Cold) object) }. Calling trace: | ||
|-> class C extends A { [ inherit-non-hot.scala:15 ] | ||
| ^ | ||
|-> val bAgain = toB.getBAgain [ inherit-non-hot.scala:16 ] | ||
| ^^^ | ||
|-> def toB: B = [ inherit-non-hot.scala:5 ] | ||
| ^ | ||
|-> if b == null then b = new B(this) // error [ inherit-non-hot.scala:6 ] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
| Promoting the value to hot (transitively initialized) failed due to the following problem: | ||
| Cannot prove that the field value a is hot. Found = Cold. Promotion trace: | ||
| -> class B(a: A) { [ inherit-non-hot.scala:10 ] | ||
| ^^^^ | ||
|Promoting the value to transitively initialized (Hot) failed due to the following problem: | ||
|Could not verify that the field value a is transitively initialized (Hot). It was found to be an uninitialized (Cold) object. Promotion trace: | ||
|-> class B(a: A) { [ inherit-non-hot.scala:10 ] | ||
| ^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
-- Error: tests/init/neg/inlined-method.scala:8:45 --------------------------------------------------------------------- | ||
8 | scala.runtime.Scala3RunTime.assertFailed(message) // error | ||
| ^^^^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class InlineError]. | ||
| Non initialized field(s): value v. Calling trace: | ||
| -> class InlineError { [ inlined-method.scala:1 ] | ||
| ^ | ||
| -> Assertion.failAssert(this) [ inlined-method.scala:2 ] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| -> scala.runtime.Scala3RunTime.assertFailed(message) // error [ inlined-method.scala:8 ] | ||
| ^^^^^^^ | ||
|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). | ||
|Non initialized field(s): value v. Calling trace: | ||
|-> class InlineError { [ inlined-method.scala:1 ] | ||
| ^ | ||
|-> Assertion.failAssert(this) [ inlined-method.scala:2 ] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|-> scala.runtime.Scala3RunTime.assertFailed(message) // error [ inlined-method.scala:8 ] | ||
| ^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
-- Error: tests/init/neg/inner-first.scala:3:12 ------------------------------------------------------------------------ | ||
3 | println(this) // error | ||
| ^^^^ | ||
| Cannot prove the method argument is hot. Only hot values are safe to leak. | ||
| Found = ThisRef[class B]. | ||
| Non initialized field(s): value n. Calling trace: | ||
| -> class B: [ inner-first.scala:2 ] | ||
| ^ | ||
| -> println(this) // error [ inner-first.scala:3 ] | ||
| ^^^^ | ||
|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). | ||
|Non initialized field(s): value n. Calling trace: | ||
|-> class B: [ inner-first.scala:2 ] | ||
| ^ | ||
|-> println(this) // error [ inner-first.scala:3 ] | ||
| ^^^^ |
Oops, something went wrong.