Skip to content

Commit 080adfb

Browse files
committed
Rebase against #5940 to set default pos in constructors
1 parent b5b4f35 commit 080adfb

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
1212
def TreeDeco(tree: Tree): TreeAPI = new TreeAPI {
1313
def pos(implicit ctx: Context): Position = tree.sourcePos
1414
def symbol(implicit ctx: Context): Symbol = tree.symbol
15-
def withPos(pos: Position)(implicit ctx: Context): Unit = tree.withSpan(pos.span)
1615
}
1716

1817
def PackageClauseDeco(pack: PackageClause): PackageClauseAPI = new PackageClauseAPI {
@@ -405,11 +404,11 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
405404
def unique(qualifier: Term, name: String)(implicit ctx: Context): Select = {
406405
val denot = qualifier.tpe.member(name.toTermName)
407406
assert(!denot.isOverloaded, s"The symbol `$name` is overloaded. The method Select.unique can only be used for non-overloaded symbols.")
408-
tpd.Select(qualifier, name.toTermName)
407+
withDefaultPos(implicit ctx => tpd.Select(qualifier, name.toTermName))
409408
}
410409

411410
def overloaded(qualifier: Term, name: String, targs: List[Type], args: List[Term])(implicit ctx: Context): Apply =
412-
tpd.applyOverloaded(qualifier, name.toTermName, args, targs, Types.WildcardType).asInstanceOf[Apply]
411+
withDefaultPos(implicit ctx => tpd.applyOverloaded(qualifier, name.toTermName, args, targs, Types.WildcardType).asInstanceOf[Apply])
413412

414413
def copy(original: Tree)(qualifier: Term, name: String)(implicit ctx: Context): Select =
415414
tpd.cpy.Select(original)(qualifier, name.toTermName)

library/src/scala/tasty/reflect/TreeOps.scala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ trait TreeOps extends Core {
4545
/** Position in the source code */
4646
def pos(implicit ctx: Context): Position
4747

48-
/** Set the position of the tree
49-
*
50-
* @note It only changes positions, not source file of the tree. Source
51-
* file of trees are derived from context and cannot be changed.
52-
*/
53-
def withPos(pos: Position)(implicit ctx: Context): Unit
54-
5548
def symbol(implicit ctx: Context): Symbol
5649
}
5750

tests/run-with-compiler/reflect-select-constructor/assert_1.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ object scalatest {
1818
let(lhs) { left =>
1919
let(rhs) { right =>
2020
val app = Term.Select.overloaded(left, op, Nil, right :: Nil)
21-
app.withPos(t.pos)
2221
let(app) { result =>
2322
val l = left.seal[Any]
2423
val r = right.seal[Any]
@@ -33,7 +32,6 @@ object scalatest {
3332
let(lhs) { left =>
3433
let(rhs) { right =>
3534
val app = Term.Select.overloaded(Term.Apply(qual, left :: Nil), op, Nil, right :: Nil)
36-
app.withPos(f.pos)
3735
let(Term.Apply(app, implicits)) { result =>
3836
val l = left.seal[Any]
3937
val r = right.seal[Any]

0 commit comments

Comments
 (0)