Skip to content

Commit 3441e15

Browse files
committed
Make sourcePos explicit
Drop sourcePos as an implicit conversion. In the presence of inlined code it's more robust to compute the right source position directly from a tree or symbol. The cases where this is not possible are now handled by an explicit `sourcePos` call.
1 parent 7390f25 commit 3441e15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+257
-229
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
384384
def debuglog(msg: => String): Unit = ctx.debuglog(msg)
385385
def informProgress(msg: String): Unit = ctx.informProgress(msg)
386386
def log(msg: => String): Unit = ctx.log(msg)
387-
def error(pos: Position, msg: String): Unit = ctx.error(msg, pos)
388-
def warning(pos: Position, msg: String): Unit = ctx.warning(msg, pos)
387+
def error(pos: Position, msg: String): Unit = ctx.error(msg, sourcePos(pos))
388+
def warning(pos: Position, msg: String): Unit = ctx.warning(msg, sourcePos(pos))
389389
def abort(msg: String): Nothing = {
390390
ctx.error(msg)
391391
throw new RuntimeException(msg)
@@ -502,7 +502,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
502502
i"""|compiler bug: created invalid generic signature for $sym in ${sym.denot.owner.showFullName}
503503
|signature: $sig
504504
|if this is reproducible, please report bug at https://github.com/lampepfl/dotty/issues
505-
""".trim, sym.pos)
505+
""".trim, sym.sourcePos)
506506
}
507507
}
508508

@@ -1105,7 +1105,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
11051105
def _1: Type = field.tpe match {
11061106
case JavaArrayType(elem) => elem
11071107
case _ =>
1108-
ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", field.pos)
1108+
error(field.pos, s"JavaSeqArray with type ${field.tpe} reached backend: $field")
11091109
UnspecifiedErrorType
11101110
}
11111111
def _2: List[Tree] = field.elems

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
163163
else (dupClassSym, classSymbol)
164164
ctx.atPhase(ctx.typerPhase) { implicit ctx =>
165165
ctx.warning(s"${cl1.show} differs only in case from ${cl2.showLocated}. " +
166-
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.pos)
166+
"Such classes will overwrite one another on case-insensitive filesystems.", cl1.sourcePos)
167167
}
168168
}
169169
}

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ class JSCodeGen()(implicit ctx: Context) {
16081608

16091609
def requireNotSuper(): Unit = {
16101610
if (jsSuperClassValue.isDefined)
1611-
ctx.error("Illegal super call in Scala.js-defined JS class", tree.pos)
1611+
ctx.error("Illegal super call in Scala.js-defined JS class", tree.sourcePos)
16121612
}
16131613

16141614
def requireNotSpread(arg: js.TreeOrJSSpread): js.Tree =
@@ -1984,7 +1984,7 @@ class JSCodeGen()(implicit ctx: Context) {
19841984
if (sym.is(Trait)) {
19851985
ctx.error(
19861986
s"isInstanceOf[${sym.fullName}] not supported because it is a JS trait",
1987-
tree.pos)
1987+
tree.sourcePos)
19881988
js.BooleanLiteral(true)
19891989
} else {
19901990
js.Unbox(js.JSBinaryOp(

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ object desugar {
351351
val constrVparamss =
352352
if (originalVparamss.isEmpty) { // ensure parameter list is non-empty
353353
if (isCaseClass && originalTparams.isEmpty)
354-
ctx.error(CaseClassMissingParamList(cdef), cdef.namePos)
354+
ctx.error(CaseClassMissingParamList(cdef), cdef.sourcePos.withPos(cdef.namePos))
355355
ListOfNil
356356
} else if (isCaseClass && originalVparamss.head.exists(_.mods.is(Implicit))) {
357-
ctx.error("Case classes should have a non-implicit parameter list", cdef.namePos)
357+
ctx.error("Case classes should have a non-implicit parameter list", cdef.sourcePos.withPos(cdef.namePos))
358358
ListOfNil
359359
}
360360
else originalVparamss.nestedMap(toDefParam)
@@ -433,7 +433,7 @@ object desugar {
433433
appliedRef(enumClassRef)
434434
else {
435435
ctx.error(i"explicit extends clause needed because both enum case and enum class have type parameters"
436-
, cdef.pos.startPos)
436+
, cdef.sourcePos.startPos)
437437
appliedTypeTree(enumClassRef, constrTparams map (_ => anyRef))
438438
}
439439

@@ -637,15 +637,15 @@ object desugar {
637637
if (!isImplicit)
638638
Nil
639639
else if (ctx.owner is Package) {
640-
ctx.error(TopLevelImplicitClass(cdef), cdef.pos)
640+
ctx.error(TopLevelImplicitClass(cdef), cdef.sourcePos)
641641
Nil
642642
}
643643
else if (isCaseClass) {
644-
ctx.error(ImplicitCaseClass(cdef), cdef.pos)
644+
ctx.error(ImplicitCaseClass(cdef), cdef.sourcePos)
645645
Nil
646646
}
647647
else if (arity != 1) {
648-
ctx.error(ImplicitClassPrimaryConstructorArity(), cdef.pos)
648+
ctx.error(ImplicitClassPrimaryConstructorArity(), cdef.sourcePos)
649649
Nil
650650
}
651651
else
@@ -713,7 +713,7 @@ object desugar {
713713
.withPos(mdef.pos.startPos)
714714
val ValDef(selfName, selfTpt, _) = impl.self
715715
val selfMods = impl.self.mods
716-
if (!selfTpt.isEmpty) ctx.error(ObjectMayNotHaveSelfType(mdef), impl.self.pos)
716+
if (!selfTpt.isEmpty) ctx.error(ObjectMayNotHaveSelfType(mdef), impl.self.sourcePos)
717717
val clsSelf = ValDef(selfName, SingletonTypeTree(Ident(moduleName)), impl.self.rhs)
718718
.withMods(selfMods)
719719
.withPos(impl.self.pos orElse impl.pos.startPos)
@@ -740,7 +740,7 @@ object desugar {
740740
*/
741741
def opaqueAlias(tdef: TypeDef)(implicit ctx: Context): Tree =
742742
if (tdef.rhs.isInstanceOf[TypeBoundsTree]) {
743-
ctx.error(em"opaque type ${tdef.name} must be an alias type", tdef.pos)
743+
ctx.error(em"opaque type ${tdef.name} must be an alias type", tdef.sourcePos)
744744
tdef.withFlags(tdef.mods.flags &~ Opaque)
745745
}
746746
else {
@@ -773,7 +773,7 @@ object desugar {
773773
val name = mdef.name
774774
if (ctx.owner == defn.ScalaPackageClass && defn.reservedScalaClassNames.contains(name.toTypeName)) {
775775
def kind = if (name.isTypeName) "class" else "object"
776-
ctx.error(em"illegal redefinition of standard $kind $name", mdef.pos)
776+
ctx.error(em"illegal redefinition of standard $kind $name", mdef.sourcePos)
777777
name.errorName
778778
}
779779
else name
@@ -1365,7 +1365,7 @@ object desugar {
13651365
elems foreach collect
13661366
case Alternative(trees) =>
13671367
for (tree <- trees; (vble, _) <- getVariables(tree))
1368-
ctx.error(IllegalVariableInPatternAlternative(), vble.pos)
1368+
ctx.error(IllegalVariableInPatternAlternative(), vble.sourcePos)
13691369
case Annotated(arg, _) =>
13701370
collect(arg)
13711371
case InterpolatedString(_, segments) =>

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import language.higherKinds
99
import collection.mutable.ListBuffer
1010
import printing.Printer
1111
import printing.Texts.Text
12-
import util.{Stats, Attachment, Property, SourceFile}
12+
import util.{Stats, Attachment, Property, SourceFile, SourcePosition}
1313
import config.Config
1414
import annotation.internal.sharable
1515
import annotation.unchecked.uncheckedVariance
@@ -68,6 +68,12 @@ object Trees {
6868

6969
def source(implicit ctx: Context): SourceFile = ctx.sourceOfTreeId(uniqueId)
7070

71+
def sourcePos(implicit ctx: Context): SourcePosition = {
72+
val src = source
73+
val srcCtx = ctx.withSource(src)
74+
Decorators.sourcePos(pos)(srcCtx)
75+
}
76+
7177
/** The type constructor at the root of the tree */
7278
type ThisTree[T >: Untyped] <: Tree[T]
7379

compiler/src/dotty/tools/dotc/core/Comments.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ object Comments {
125125
val newName = ctx.freshNames.newName(tree.name, NameKinds.DocArtifactName)
126126
tree.copy(name = newName)
127127
case _ =>
128-
ctx.error(ProperDefinitionNotFound(), codePos)
128+
ctx.error(ProperDefinitionNotFound(), sourcePos(codePos))
129129
tree
130130
}
131131
}

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ object Decorators {
165165
}
166166
}
167167

168-
implicit def sourcePos(pos: Position)(implicit ctx: Context): SourcePosition = {
168+
def sourcePos(pos: Position)(implicit ctx: Context): SourcePosition = {
169169
def recur(inlinedCalls: List[Tree], pos: Position): SourcePosition = inlinedCalls match {
170170
case inlinedCall :: rest =>
171171
sourceFile(inlinedCall).atPos(pos).withOuter(recur(rest, inlinedCall.pos))

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ object SymDenotations {
21082108
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
21092109
val sym = denot.symbol
21102110
def errMsg = BadSymbolicReference(denot)
2111-
ctx.error(errMsg, sym.pos)
2111+
ctx.error(errMsg, sym.sourcePos)
21122112
if (ctx.debug) throw new scala.Error()
21132113
initializeToDefaults(denot, errMsg)
21142114
}

compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ object SymbolLoaders {
134134
ctx.warning(i"""$what ${tree.name} is in the wrong directory.
135135
|It was declared to be in package ${path.reverse.mkString(".")}
136136
|But it is found in directory ${filePath.reverse.mkString(File.separator)}""",
137-
tree.pos)
137+
tree.sourcePos)
138138
ok
139139
}
140140

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import reporting.diagnostic.Message
2626
import collection.mutable
2727
import io.AbstractFile
2828
import language.implicitConversions
29-
import util.{NoSource, Property}
29+
import util.{NoSource, Property, SourcePosition}
3030
import scala.collection.JavaConverters._
3131
import scala.annotation.internal.sharable
3232
import config.Printers.typr
@@ -656,6 +656,15 @@ object Symbols {
656656
*/
657657
final def pos: Position = if (coord.isPosition) coord.toPosition else NoPosition
658658

659+
final def sourcePos(implicit ctx: Context): SourcePosition = {
660+
val source = {
661+
val f = sourceFile
662+
if (f == null) ctx.source
663+
else ctx.getSource(f)
664+
}
665+
SourcePosition(source, pos)
666+
}
667+
659668
// ParamInfo types and methods
660669
def isTypeParam(implicit ctx: Context): Boolean = denot.is(TypeParam)
661670
def paramName(implicit ctx: Context): ThisName = name.asInstanceOf[ThisName]

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
322322

323323
def testScala2Mode(msg: => Message, pos: Position, replace: => Unit = ()): Boolean = {
324324
if (scala2Mode) {
325-
migrationWarning(msg, pos)
325+
migrationWarning(msg, sourcePos(pos))
326326
replace
327327
}
328328
scala2Mode

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class TreePickler(pickler: TastyPickler) {
7979
// I believe it's a bug in typer: the type of an implicit argument refers
8080
// to a closure parameter outside the closure itself. TODO: track this down, so that we
8181
// can eliminate this case.
82-
ctx.log(i"pickling reference to as yet undefined $sym in ${sym.owner}", sym.pos)
82+
ctx.log(i"pickling reference to as yet undefined $sym in ${sym.owner}", sym.sourcePos)
8383
pickleForwardSymRef(sym)
8484
}
8585

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
311311
val txt = tree.typeOpt match {
312312
case tp: NamedType if name != nme.WILDCARD =>
313313
val pre = if (tp.symbol is JavaStatic) tp.prefix.widen else tp.prefix
314-
toTextPrefix(pre) ~ withPos(selectionString(tp), tree.pos)
314+
toTextPrefix(pre) ~ withPos(selectionString(tp), tree.sourcePos)
315315
case _ =>
316316
toText(name)
317317
}
@@ -335,8 +335,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
335335
typeApplyText(tree)
336336
case Literal(c) =>
337337
tree.typeOpt match {
338-
case ConstantType(tc) => withPos(toText(tc), tree.pos)
339-
case _ => withPos(toText(c), tree.pos)
338+
case ConstantType(tc) => withPos(toText(tc), tree.sourcePos)
339+
case _ => withPos(toText(c), tree.sourcePos)
340340
}
341341
case New(tpt) =>
342342
keywordStr("new ") ~ {
@@ -501,7 +501,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
501501
case SymbolLit(str) =>
502502
"'" + str
503503
case InterpolatedString(id, segments) =>
504-
def strText(str: Literal) = withPos(escapedString(str.const.stringValue), tree.pos)
504+
def strText(str: Literal) = withPos(escapedString(str.const.stringValue), tree.sourcePos)
505505
def segmentText(segment: Tree) = segment match {
506506
case Thicket(List(str: Literal, expr)) => strText(str) ~ "{" ~ toTextGlobal(expr) ~ "}"
507507
case str: Literal => strText(str)
@@ -642,8 +642,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
642642
if (tree.hasType && tree.symbol.exists) {
643643
val str: Text = nameString(tree.symbol)
644644
tree match {
645-
case tree: RefTree => withPos(str, tree.pos)
646-
case tree: MemberDef => withPos(str, tree.namePos)
645+
case tree: RefTree => withPos(str, tree.sourcePos)
646+
case tree: MemberDef => withPos(str, tree.sourcePos.withPos(tree.namePos))
647647
case _ => str
648648
}
649649
}

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ object messages {
21032103
case _ /* Signature.FullMatch */ => "\nThe definitions have matching type signatures after erasure."
21042104
}
21052105
} else ""
2106-
hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} at line ${previousDecl.pos.line + 1}." + details
2106+
hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} at line ${previousDecl.sourcePos.line + 1}." + details
21072107
}
21082108
val explanation: String = ""
21092109
}

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
246246
case ex: TypeError =>
247247
// See neg/i1750a for an example where a cyclic error can arise.
248248
// The root cause in this example is an illegal "override" of an inner trait
249-
ctx.error(ex.toMessage, csym.pos)
249+
ctx.error(ex.toMessage, csym.sourcePos)
250250
defn.ObjectType :: Nil
251251
}
252252
if (ValueClasses.isDerivedValueClass(csym)) {

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
235235
ctx.warning("""|No class, trait or object is defined in the compilation unit.
236236
|The incremental compiler cannot record the dependency information in such case.
237237
|Some errors like unused import referring to a non-existent class might not be reported.
238-
|""".stripMargin, tree.pos)
238+
|""".stripMargin, tree.sourcePos)
239239
}
240240
_responsibleForImports
241241
}

compiler/src/dotty/tools/dotc/tastyreflect/IdOpsImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import dotty.tools.dotc.core.Decorators._
55
trait IdOpsImpl extends scala.tasty.reflect.IdOps with CoreImpl {
66

77
def IdDeco(id: Id): IdAPI = new IdAPI {
8-
def pos(implicit ctx: Context): Position = id.pos
8+
def pos(implicit ctx: Context): Position = id.sourcePos
99
def name(implicit ctx: Context): String = id.name.toString
1010
}
1111

compiler/src/dotty/tools/dotc/tastyreflect/PatternOpsImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with CoreImpl {
3434
// ----- Patterns -------------------------------------------------
3535

3636
def PatternDeco(pattern: Pattern): PatternAPI = new PatternAPI {
37-
def pos(implicit ctx: Context): Position = pattern.pos
37+
def pos(implicit ctx: Context): Position = pattern.sourcePos
3838
def tpe(implicit ctx: Context): Type = pattern.tpe.stripTypeVar
3939
}
4040

compiler/src/dotty/tools/dotc/tastyreflect/SymbolOpsImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait SymbolOpsImpl extends scala.tasty.reflect.SymbolOps with CoreImpl {
2626
def name(implicit ctx: Context): String = symbol.name.toString
2727
def fullName(implicit ctx: Context): String = symbol.fullName.toString
2828

29-
def pos(implicit ctx: Context): Position = symbol.pos
29+
def pos(implicit ctx: Context): Position = symbol.sourcePos
3030

3131
def owner(implicit ctx: Context): Symbol = symbol.owner
3232

compiler/src/dotty/tools/dotc/tastyreflect/TreeOpsImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import dotty.tools.dotc.tastyreflect.FromSymbol.{definitionFromSym, packageDefFr
1010
trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers {
1111

1212
def TreeDeco(tree: Tree): TreeAPI = new TreeAPI {
13-
def pos(implicit ctx: Context): Position = tree.pos
13+
def pos(implicit ctx: Context): Position = tree.sourcePos
1414
def symbol(implicit ctx: Context): Symbol = tree.symbol
1515
}
1616

@@ -353,7 +353,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
353353

354354
def TermDeco(term: Term): TermAPI = new TermAPI {
355355
import tpd._
356-
def pos(implicit ctx: Context): Position = term.pos
356+
def pos(implicit ctx: Context): Position = term.sourcePos
357357
def tpe(implicit ctx: Context): Type = term.tpe
358358
def underlyingArgument(implicit ctx: Context): Term = term.underlyingArgument
359359
def underlying(implicit ctx: Context): Term = term.underlying

compiler/src/dotty/tools/dotc/tastyreflect/TypeOrBoundsTreesOpsImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import dotty.tools.dotc.core.{Contexts, Types}
99
trait TypeOrBoundsTreesOpsImpl extends scala.tasty.reflect.TypeOrBoundsTreeOps with CoreImpl {
1010

1111
def TypeTreeDeco(tpt: TypeTree): TypeTreeAPI = new TypeTreeAPI {
12-
def pos(implicit ctx: Context): Position = tpt.pos
12+
def pos(implicit ctx: Context): Position = tpt.sourcePos
1313
def symbol(implicit ctx: Context): Symbol = tpt.symbol
1414
def tpe(implicit ctx: Context): Type = tpt.tpe.stripTypeVar
1515
}

compiler/src/dotty/tools/dotc/transform/AccessProxies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ abstract class AccessProxies {
143143
def accessorIfNeeded(tree: Tree)(implicit ctx: Context): Tree = tree match {
144144
case tree: RefTree if needsAccessor(tree.symbol) =>
145145
if (tree.symbol.isConstructor) {
146-
ctx.error("Implementation restriction: cannot use private constructors in inlineable methods", tree.pos)
146+
ctx.error("Implementation restriction: cannot use private constructors in inlineable methods", tree.sourcePos)
147147
tree // TODO: create a proper accessor for the private constructor
148148
}
149149
else useAccessor(tree)

compiler/src/dotty/tools/dotc/transform/Bridges.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ast.untpd
99
import collection.{mutable, immutable}
1010
import ShortcutImplicits._
1111
import util.Positions.Position
12+
import util.SourcePosition
1213

1314
/** A helper class for generating bridge methods in class `root`. */
1415
class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Context) {
@@ -40,8 +41,8 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Cont
4041
private val bridgesScope = newScope
4142
private val bridgeTarget = newMutableSymbolMap[Symbol]
4243

43-
def bridgePosFor(member: Symbol): Position =
44-
if (member.owner == root && member.pos.exists) member.pos else root.pos
44+
def bridgePosFor(member: Symbol): SourcePosition =
45+
(if (member.owner == root && member.pos.exists) member else root).sourcePos
4546

4647
/** Add a bridge between `member` and `other`, where `member` overrides `other`
4748
* before erasure, if the following conditions are satisfied.
@@ -85,7 +86,7 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Cont
8586
owner = root,
8687
flags = (member.flags | Method | Bridge | Artifact) &~
8788
(Accessor | ParamAccessor | CaseAccessor | Deferred | Lazy | Module),
88-
coord = bridgePosFor(member)).enteredAfter(thisPhase).asTerm
89+
coord = bridgePosFor(member).pos).enteredAfter(thisPhase).asTerm
8990

9091
ctx.debuglog(
9192
i"""generating bridge from ${other.showLocated}: ${other.info}

0 commit comments

Comments
 (0)