Skip to content

Commit 1c4af73

Browse files
committed
Revert "Remove DottyBackendInterface.sourcePos"
This reverts commit c0e01e9.
1 parent 3a0dbda commit 1c4af73

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
664664
var elemKind = arr.elementType
665665
val argsSize = args.length
666666
if (argsSize > dims) {
667-
ctx.error(s"too many arguments for array constructor: found ${args.length} but array has only $dims dimension(s)", app.sourcePos)
667+
ctx.error(s"too many arguments for array constructor: found ${args.length} but array has only $dims dimension(s)", sourcePos(app.span))
668668
}
669669
if (argsSize < dims) {
670670
/* In one step:

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
5959
outputDirectory
6060
} catch {
6161
case ex: Throwable =>
62-
ctx.error(s"Couldn't create file for class $cName\n${ex.getMessage}", csym.sourcePos)
62+
ctx.error(s"Couldn't create file for class $cName\n${ex.getMessage}", sourcePos(csym.span))
6363
null
6464
}
6565
}

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
404404
val loc = Local(tk, sym.name.mangledString.toString, nxtIdx, sym.is(Flags.Synthetic))
405405
val existing = slots.put(sym, loc)
406406
if (existing.isDefined)
407-
ctx.error("attempt to create duplicate local var.", sym.sourcePos)
407+
ctx.error("attempt to create duplicate local var.", sourcePos(sym.span))
408408
assert(tk.size > 0, "makeLocal called for a symbol whose type is Unit.")
409409
nxtIdx += tk.size
410410
loc
@@ -454,7 +454,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
454454
}
455455
def lineNumber(tree: Tree): Unit = {
456456
if (!emitLines || !tree.span.exists) return;
457-
val nr = tree.sourcePos.line + 1
457+
val nr = sourcePos(tree.span).line + 1
458458
if (nr != lastEmittedLineNr) {
459459
lastEmittedLineNr = nr
460460
lastInsn match {
@@ -557,7 +557,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
557557

558558
if (params.size > MaximumJvmParameters) {
559559
// SI-7324
560-
ctx.error(s"Platform restriction: a parameter list's length cannot exceed $MaximumJvmParameters.", methSymbol.sourcePos)
560+
ctx.error(s"Platform restriction: a parameter list's length cannot exceed $MaximumJvmParameters.", sourcePos(methSymbol.span))
561561
return
562562
}
563563

@@ -586,7 +586,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
586586
ctx.error("Concrete method has no definition: " + dd + (
587587
if (ctx.settings.Ydebug.value) "(found: " + methSymbol.owner.info.decls.toList.mkString(", ") + ")"
588588
else ""),
589-
ctx.source.atSpan(NoSpan)
589+
sourcePos(NoSpan)
590590
)
591591
case _ =>
592592
bc emitRETURN returnType

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
7575
ctx.error(msg)
7676
throw new RuntimeException(msg)
7777
}
78+
def sourcePos(pos: Spans.Span)(implicit ctx: Context): util.SourcePosition =
79+
ctx.source.atSpan(pos)
7880

7981
val perRunCaches: Caches = new Caches {
8082
def newAnyRefMap[K <: AnyRef, V](): mutable.AnyRefMap[K, V] = new mutable.AnyRefMap[K, V]()
@@ -325,7 +327,7 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
325327
def _1: Type = field.tpe match {
326328
case JavaArrayType(elem) => elem
327329
case _ =>
328-
ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", field.sourcePos)
330+
ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", sourcePos(field.span))
329331
UnspecifiedErrorType
330332
}
331333
def _2: List[Tree] = field.elems

0 commit comments

Comments
 (0)