Skip to content

Commit e6f56b9

Browse files
committed
withPos(Positioned) -> withPosOf
1 parent 4b6b983 commit e6f56b9

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ abstract class Positioned(implicit @transientParam src: SourceInfo) extends Prod
5252
*/
5353
def withPos(pos: Position)(implicit src: SourceInfo): this.type = {
5454
val ownPos = this.pos
55-
val newpd: this.type = if (pos == ownPos || ownPos.isSynthetic) this else cloneIn(srcfile)
55+
val newpd: this.type =
56+
if (pos == ownPos || ownPos.isSynthetic) this else cloneIn(srcfile)
5657
newpd.setPos(pos, srcfile)
5758
newpd
5859
}
5960

60-
def withPos(posd: Positioned)(implicit ctx: Context): this.type = {
61+
def withPosOf(posd: Positioned)(implicit ctx: Context): this.type = {
6162
val ownPos = this.pos
6263
val newpd: this.type =
6364
if (posd.source == source && posd.pos == ownPos || ownPos.isSynthetic) this

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ByNameClosures extends TransformByNameApply with IdentityDenotTransformer
2828
override def mkByNameClosure(arg: Tree, argType: Type)(implicit ctx: Context): Tree = {
2929
val meth = ctx.newSymbol(
3030
ctx.owner, nme.ANON_FUN, Synthetic | Method, MethodType(Nil, Nil, argType))
31-
Closure(meth, _ => arg.changeOwnerAfter(ctx.owner, meth, thisPhase)).withPos(arg)
31+
Closure(meth, _ => arg.changeOwnerAfter(ctx.owner, meth, thisPhase)).withPosOf(arg)
3232
}
3333
}
3434

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class TransformByNameApply extends MiniPhase { thisPhase: DenotTransfor
4444
var argType = arg.tpe.widenIfUnstable
4545
if (defn.isBottomType(argType)) argType = formal.widenExpr
4646
def wrap(arg: Tree) =
47-
ref(defn.cbnArg).appliedToType(argType).appliedTo(arg).withPos(arg)
47+
ref(defn.cbnArg).appliedToType(argType).appliedTo(arg).withPosOf(arg)
4848
arg match {
4949
case Apply(Select(qual, nme.apply), Nil)
5050
if qual.tpe.derivesFrom(defn.FunctionClass(0)) && isPureExpr(qual) =>

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ object Inliner {
6969
override def transform(t: Tree)(implicit ctx: Context) = {
7070
t match {
7171
case Inlined(t, Nil, expr) if t.isEmpty => expr
72-
case _ => super.transform(t.withSourcePos(call.sourcePos))
72+
case _ => super.transform(t.withPosOf(call))
7373
}
7474
}
7575
}
@@ -137,7 +137,7 @@ object Inliner {
137137
case call :: _ if call.symbol.sourceFile != curSourceFile =>
138138
// Until we implement JSR-45, we cannot represent in output positions in other source files.
139139
// So, reposition inlined code from other files with the call position:
140-
transformed.withSourcePos(inlinedAtPos)
140+
transformed.withPosOf(inlined.call)
141141
case _ => transformed
142142
}
143143
}
@@ -419,7 +419,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
419419
case Some(t) if tree.isTerm && t.isSingleton =>
420420
singleton(t.dealias)
421421
case Some(t) if tree.isType =>
422-
TypeTree(t).withSourcePos(tree.sourcePos)
422+
TypeTree(t).withPosOf(tree)
423423
case _ => tree
424424
}
425425
case tree => tree
@@ -430,7 +430,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
430430

431431
// Apply inliner to `rhsToInline`, split off any implicit bindings from result, and
432432
// make them part of `bindingsBuf`. The expansion is then the tree that remains.
433-
val expansion = inliner.transform(rhsToInline).withSourcePos(call.sourcePos)
433+
val expansion = inliner.transform(rhsToInline).withPosOf(call)
434434

435435
def issueError() = callValueArgss match {
436436
case (msgArg :: rest) :: Nil =>
@@ -596,7 +596,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
596596
case _ =>
597597
binding
598598
}
599-
binding1.withSourcePos(call.sourcePos)
599+
binding1.withPosOf(call)
600600
}
601601

602602
/** An extractor for references to inlineable arguments. These are :
@@ -1008,7 +1008,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
10081008
val t1 = t match {
10091009
case t: RefTree =>
10101010
if (t.name != nme.WILDCARD && boundTypes.contains(t.symbol))
1011-
TypeTree(dealiasedType).withSourcePos(t.sourcePos)
1011+
TypeTree(dealiasedType).withPosOf(t)
10121012
else t.withType(dealiasedType)
10131013
case t: DefTree =>
10141014
t.symbol.info = dealias(t.symbol.info)

0 commit comments

Comments
 (0)