Skip to content

Commit bac5c81

Browse files
committed
Show full path for external code without source
1 parent 9959ff7 commit bac5c81

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ object Trace:
6060
val hasSource = fileExists(pos.source)
6161
val line =
6262
if pos.exists then
63-
val loc = pos.source.file.name + ":" + (pos.line + 1)
63+
// Show more information for external code without source
64+
val file = if hasSource then pos.source.file.name else pos.source.file.path
65+
val loc = file + ":" + (pos.line + 1)
6466
val code =
6567
if hasSource then
6668
SyntaxHighlighting.highlight(pos.lineContent.trim)

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class CompilationTests {
259259
val outDirLib = defaultOutputDir + group + "/A/tastySource/A"
260260

261261
// Set -sourceroot such that the source code cannot be found by the compiler
262-
val libOptions = tastSourceOptions.and("-sourceroot", "tests/init-global/special/tastySource")
262+
val libOptions = tastSourceOptions.and("-sourceroot", "tests/init-global/special")
263263
val lib = compileFile("tests/init-global/special/tastySource/A.scala", libOptions)(group).keepOutput.checkCompile()
264264

265265
compileFile("tests/init-global/special/tastySource/B.scala", tastSourceOptions.withClasspath(outDirLib))(group).checkWarnings()

tests/init-global/special/tastySource/B.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace:
66
|├── object B: [ B.scala:1 ]
77
|│ ^
8-
|├── (no source) [ A.scala:2 ]
9-
|├── (no source) [ A.scala:4 ]
8+
|├── (no source) [ tastySource/A.scala:2 ]
9+
|├── (no source) [ tastySource/A.scala:4 ]
1010
|├── var y = A.foo(bar) * 2 [ B.scala:2 ]
1111
|│ ^^^
1212
|└── def bar = C.n * 3 // warn [ B.scala:4 ]

0 commit comments

Comments
 (0)