Skip to content

Commit 733af41

Browse files
committed
Check if source exists for inline positions
1 parent e347416 commit 733af41

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ trait MessageRendering {
236236
sb.append(EOL).append(newBox())
237237
sb.append(EOL).append(offsetBox).append(i"Inline stack trace")
238238
for inlinedPos <- inlineStack if inlinedPos != pos1 do
239-
val (srcBefore, srcAfter, offset) = sourceLines(inlinedPos)
240-
val marker = positionMarker(inlinedPos)
241239
sb.append(EOL).append(newBox(soft = true))
242240
sb.append(EOL).append(offsetBox).append(i"This location contains code that was inlined from $pos")
243-
sb.append(EOL).append((srcBefore ::: marker :: srcAfter).mkString(EOL))
241+
if inlinedPos.source.file.exists then
242+
val (srcBefore, srcAfter, _) = sourceLines(inlinedPos)
243+
val marker = positionMarker(inlinedPos)
244+
sb.append(EOL).append((srcBefore ::: marker :: srcAfter).mkString(EOL))
244245
sb.append(EOL).append(endBox)
245246
}
246247
else sb.append(msg.message)

project/scripts/cmdTests

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cp tests/neg/i6371/B_2.scala $OUT/B.scala
5656
"$SBT" "scalac $OUT/A.scala -d $OUT1"
5757
rm $OUT/A.scala
5858
"$SBT" "scalac -classpath $OUT1 -d $OUT1 $OUT/B.scala" > "$tmp" 2>&1 || echo "ok"
59+
cat "$tmp" # for debugging
5960
grep -qe "B.scala:2:7" "$tmp"
6061
grep -qe "This location contains code that was inlined from A.scala:3" "$tmp"
6162

0 commit comments

Comments
 (0)