Skip to content

Commit 6de011c

Browse files
committed
Fix warning underlining in global init checker
1 parent 8020677 commit 6de011c

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ object Trace:
7777
* pos.source must exist
7878
*/
7979
private def positionMarker(pos: SourcePosition): String =
80-
val trimmed = pos.lineContent.takeWhile(c => c.isWhitespace).length
80+
val trimmed = pos.source.lineContent(pos.start).takeWhile(c => c.isWhitespace).length
8181
val padding = pos.startColumnPadding.substring(trimmed).nn + " "
8282
val carets =
8383
if (pos.startLine == pos.endLine)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Error: tests/init-global/neg/line-spacing.scala:4:7 -----------------------------------------------------------------
2+
3 | B
3+
4 | .s.length // error
4+
| ^
5+
| Access uninitialized field value s. Call trace:
6+
| -> object B { [ line-spacing.scala:7 ]
7+
| ^
8+
| -> val s: String = s"${A.a}a" [ line-spacing.scala:8 ]
9+
| ^^^
10+
| -> def a: Int = [ line-spacing.scala:2 ]
11+
| ^
12+
| -> .s.length // error [ line-spacing.scala:4 ]
13+
| ^
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object A {
2+
def a: Int =
3+
B
4+
.s.length // error
5+
}
6+
7+
object B {
8+
val s: String = s"${A.a}a"
9+
}
10+
11+
@main
12+
def Test = print(A.a)

0 commit comments

Comments
 (0)