Skip to content

Commit a03fa03

Browse files
committed
Inline sourcePos
1 parent 0cabe6f commit a03fa03

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
666666
var elemKind = arr.elementType
667667
val argsSize = args.length
668668
if (argsSize > dims) {
669-
ctx.error(s"too many arguments for array constructor: found ${args.length} but array has only $dims dimension(s)", sourcePos(app.span))
669+
ctx.error(s"too many arguments for array constructor: found ${args.length} but array has only $dims dimension(s)", ctx.source.atSpan(app.span))
670670
}
671671
if (argsSize < dims) {
672672
/* 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
@@ -66,7 +66,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
6666
outputDirectory
6767
} catch {
6868
case ex: Throwable =>
69-
ctx.error(s"Couldn't create file for class $cName\n${ex.getMessage}", sourcePos(csym.span))
69+
ctx.error(s"Couldn't create file for class $cName\n${ex.getMessage}", ctx.source.atSpan(csym.span))
7070
null
7171
}
7272
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
407407
val loc = Local(tk, sym.name.mangledString.toString, nxtIdx, sym.is(Flags.Synthetic))
408408
val existing = slots.put(sym, loc)
409409
if (existing.isDefined)
410-
ctx.error("attempt to create duplicate local var.", sourcePos(sym.span))
410+
ctx.error("attempt to create duplicate local var.", ctx.source.atSpan(sym.span))
411411
assert(tk.size > 0, "makeLocal called for a symbol whose type is Unit.")
412412
nxtIdx += tk.size
413413
loc
@@ -457,7 +457,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
457457
}
458458
def lineNumber(tree: Tree): Unit = {
459459
if (!emitLines || !tree.span.exists) return;
460-
val nr = sourcePos(tree.span).line + 1
460+
val nr = ctx.source.atSpan(tree.span).line + 1
461461
if (nr != lastEmittedLineNr) {
462462
lastEmittedLineNr = nr
463463
lastInsn match {
@@ -560,7 +560,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
560560

561561
if (params.size > MaximumJvmParameters) {
562562
// SI-7324
563-
ctx.error(s"Platform restriction: a parameter list's length cannot exceed $MaximumJvmParameters.", sourcePos(methSymbol.span))
563+
ctx.error(s"Platform restriction: a parameter list's length cannot exceed $MaximumJvmParameters.", ctx.source.atSpan(methSymbol.span))
564564
return
565565
}
566566

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

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
7070
ctx.error(msg)
7171
throw new RuntimeException(msg)
7272
}
73-
def sourcePos(pos: Spans.Span)(implicit ctx: Context): util.SourcePosition =
74-
ctx.source.atSpan(pos)
7573

7674
private val desugared = new java.util.IdentityHashMap[Type, tpd.Select]
7775

@@ -181,7 +179,7 @@ class DottyBackendInterface(val outputDirectory: AbstractFile, val superCallsMap
181179
def _1: Type = field.tpe match {
182180
case JavaArrayType(elem) => elem
183181
case _ =>
184-
ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", sourcePos(field.span))
182+
ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", ctx.source.atSpan(field.span))
185183
UnspecifiedErrorType
186184
}
187185
def _2: List[Tree] = field.elems

0 commit comments

Comments
 (0)