Commit 18300d0
committed
Add context to safe-init warnings for inlined methods
Closes #14467
- Adds the calling context of the inlined method to the stack trace for safe-init warnings
For source code:
```Scala
class InlineError {
Assertion.failAssert(this)
val v = 2;
}
object Assertion:
transparent inline def failAssert(inline message: => Any): Unit =
scala.runtime.Scala3RunTime.assertFailed(message)
```
Old warning:
```
[error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/InlineError.scala:10:45
[error] 10 | scala.runtime.Scala3RunTime.assertFailed(message)
[error] | ^^^^^^^
[error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments.
```
New warning:
```
[error] -- Error: /*******/dotty/compiler/src/dotty/tools/dotc/InlineError.scala:10:45
[error] 10 | scala.runtime.Scala3RunTime.assertFailed(message)
[error] | ^^^^^^^
[error] |Cannot prove that the value is fully initialized. Only initialized values may be used as arguments. Calling trace:
[error] | -> Assertion.failAssert(this) [ InlineError.scala:4 ]
```
Review by @liufengyun1 parent 808c669 commit 18300d0
File tree
3 files changed
+15
-1
lines changed- compiler/src/dotty/tools/dotc/transform/init
- tests/init/neg
3 files changed
+15
-1
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1239 | 1239 | | |
1240 | 1240 | | |
1241 | 1241 | | |
| 1242 | + | |
1242 | 1243 | | |
1243 | | - | |
| 1244 | + | |
1244 | 1245 | | |
1245 | 1246 | | |
1246 | 1247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments