Skip to content

Commit e8f6bda

Browse files
committed
Rename Span#pos -> Span#span
Also, related uses of `pos` local variables are renamed to `span`.
1 parent 4534fd3 commit e8f6bda

Some content is hidden

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

49 files changed

+415
-414
lines changed

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class JSCodeGen()(implicit ctx: Context) {
484484
* Other (normal) methods are emitted with `genMethodBody()`.
485485
*/
486486
private def genMethodWithCurrentLocalNameScope(dd: DefDef): Option[js.MethodDef] = {
487-
implicit val pos = dd.pos
487+
implicit val pos = dd.span
488488
val sym = dd.symbol
489489
val vparamss = dd.vparamss
490490
val rhs = dd.rhs
@@ -579,7 +579,7 @@ class JSCodeGen()(implicit ctx: Context) {
579579
private def genMethodDef(static: Boolean, methodName: js.PropertyName,
580580
paramsSyms: List[Symbol], resultIRType: jstpe.Type,
581581
tree: Tree, optimizerHints: OptimizerHints): js.MethodDef = {
582-
implicit val pos = tree.pos
582+
implicit val pos = tree.span
583583

584584
ctx.debuglog("genMethod " + methodName.encodedName)
585585
ctx.debuglog("")
@@ -598,7 +598,7 @@ class JSCodeGen()(implicit ctx: Context) {
598598
js.MethodDef(static, methodName, jsParams, resultIRType, Some(genBody()))(
599599
optimizerHints, None)
600600
/*} else {
601-
assert(!static, tree.pos)
601+
assert(!static, tree.span)
602602
603603
withScopedVars(
604604
thisLocalVarIdent := Some(freshLocalIdent("this"))
@@ -639,7 +639,7 @@ class JSCodeGen()(implicit ctx: Context) {
639639
private def genExpr(tree: Tree): js.Tree = {
640640
val result = genStatOrExpr(tree, isStat = false)
641641
assert(result.tpe != jstpe.NoType,
642-
s"genExpr($tree) returned a tree with type NoType at pos ${tree.pos}")
642+
s"genExpr($tree) returned a tree with type NoType at pos ${tree.span}")
643643
result
644644
}
645645

@@ -649,7 +649,7 @@ class JSCodeGen()(implicit ctx: Context) {
649649
* is transformed into an equivalent portion of the JS AST.
650650
*/
651651
private def genStatOrExpr(tree: Tree, isStat: Boolean): js.Tree = {
652-
implicit val pos = tree.pos
652+
implicit val pos = tree.span
653653

654654
ctx.debuglog(" " + tree)
655655
ctx.debuglog("")
@@ -660,7 +660,7 @@ class JSCodeGen()(implicit ctx: Context) {
660660
/* Must have been eliminated by the tail call transform performed
661661
* by genMethodBody(). */
662662
assert(name != nme.THIS,
663-
s"ValDef(_, nme.THIS, _, _) found at ${tree.pos}")
663+
s"ValDef(_, nme.THIS, _, _) found at ${tree.span}")
664664

665665
val sym = tree.symbol
666666
val rhs = tree.rhs
@@ -719,7 +719,7 @@ class JSCodeGen()(implicit ctx: Context) {
719719
"Trying to access the this of another class: " +
720720
"tree.symbol = " + tree.symbol +
721721
", class symbol = " + currentClassSym.get +
722-
" pos:" + pos)
722+
" span:" + pos)
723723
genLoadModule(tree.symbol)
724724
}
725725

@@ -856,7 +856,7 @@ class JSCodeGen()(implicit ctx: Context) {
856856

857857
case _ =>
858858
throw new FatalError("Unexpected tree in genExpr: " +
859-
tree + "/" + tree.getClass + " at: " + (tree.pos: Position))
859+
tree + "/" + tree.getClass + " at: " + (tree.span: Position))
860860
}
861861
} // end of genStatOrExpr()
862862

@@ -897,7 +897,7 @@ class JSCodeGen()(implicit ctx: Context) {
897897
* primitives, JS calls, etc. They are further dispatched in here.
898898
*/
899899
private def genApply(tree: Apply, isStat: Boolean): js.Tree = {
900-
implicit val pos = tree.pos
900+
implicit val pos = tree.span
901901
val args = tree.args
902902
val sym = tree.fun.symbol
903903

@@ -944,7 +944,7 @@ class JSCodeGen()(implicit ctx: Context) {
944944
* irrelevant.
945945
*/
946946
private def genSuperCall(tree: Apply, isStat: Boolean): js.Tree = {
947-
implicit val pos = tree.pos
947+
implicit val pos = tree.span
948948
val Apply(fun @ Select(sup @ Super(_, mix), _), args) = tree
949949
val sym = fun.symbol
950950

@@ -955,7 +955,7 @@ class JSCodeGen()(implicit ctx: Context) {
955955
genJSSuperCall(tree, isStat)
956956
} else*/ {
957957
val superCall = genApplyMethodStatically(
958-
genThis()(sup.pos), sym, genActualArgs(sym, args))
958+
genThis()(sup.span), sym, genActualArgs(sym, args))
959959

960960
// Initialize the module instance just after the super constructor call.
961961
if (isStaticModule(currentClassSym) && !isModuleInitialized &&
@@ -980,7 +980,7 @@ class JSCodeGen()(implicit ctx: Context) {
980980
* * regular new
981981
*/
982982
private def genApplyNew(tree: Apply): js.Tree = {
983-
implicit val pos = tree.pos
983+
implicit val pos = tree.span
984984

985985
val Apply(fun @ Select(New(tpt), nme.CONSTRUCTOR), args) = tree
986986
val ctor = fun.symbol
@@ -1038,7 +1038,7 @@ class JSCodeGen()(implicit ctx: Context) {
10381038
private def genPrimitiveOp(tree: Apply, isStat: Boolean): js.Tree = {
10391039
import scala.tools.nsc.backend.ScalaPrimitivesOps._
10401040

1041-
implicit val pos = tree.pos
1041+
implicit val pos = tree.span
10421042

10431043
val Apply(fun, args) = tree
10441044
val receiver = qualifierOf(fun)
@@ -1078,7 +1078,7 @@ class JSCodeGen()(implicit ctx: Context) {
10781078
private def genSimpleUnaryOp(tree: Apply, arg: Tree, code: Int): js.Tree = {
10791079
import scala.tools.nsc.backend.ScalaPrimitivesOps._
10801080

1081-
implicit val pos = tree.pos
1081+
implicit val pos = tree.span
10821082

10831083
val resultIRType = toIRType(tree.tpe)
10841084
val genArg = adaptPrimitive(genExpr(arg), resultIRType)
@@ -1120,7 +1120,7 @@ class JSCodeGen()(implicit ctx: Context) {
11201120
import scala.tools.nsc.backend.ScalaPrimitivesOps._
11211121
import js.UnaryOp._
11221122

1123-
implicit val pos = tree.pos
1123+
implicit val pos = tree.span
11241124

11251125
val lhsIRType = toIRType(lhs.tpe)
11261126
val rhsIRType = toIRType(rhs.tpe)
@@ -1423,7 +1423,7 @@ class JSCodeGen()(implicit ctx: Context) {
14231423
*/
14241424
private def genStringConcat(tree: Apply, receiver: Tree,
14251425
args: List[Tree]): js.Tree = {
1426-
implicit val pos = tree.pos
1426+
implicit val pos = tree.span
14271427

14281428
val arg = args.head
14291429

@@ -1450,7 +1450,7 @@ class JSCodeGen()(implicit ctx: Context) {
14501450

14511451
/** Gen JS code for a call to Any.## */
14521452
private def genScalaHash(tree: Apply, receiver: Tree): js.Tree = {
1453-
implicit val pos = tree.pos
1453+
implicit val pos = tree.span
14541454

14551455
genModuleApplyMethod(defn.ScalaRuntimeModule.requiredMethod(nme.hash_),
14561456
List(genExpr(receiver)))
@@ -1460,7 +1460,7 @@ class JSCodeGen()(implicit ctx: Context) {
14601460
private def genArrayOp(tree: Tree, code: Int): js.Tree = {
14611461
import scala.tools.nsc.backend.ScalaPrimitivesOps._
14621462

1463-
implicit val pos = tree.pos
1463+
implicit val pos = tree.span
14641464

14651465
val Apply(fun, args) = tree
14661466
val arrayObj = qualifierOf(fun)
@@ -1512,7 +1512,7 @@ class JSCodeGen()(implicit ctx: Context) {
15121512
// common case for which there is no side-effect nor NPE
15131513
genArg
15141514
case _ =>
1515-
implicit val pos = tree.pos
1515+
implicit val pos = tree.span
15161516
/* TODO Check for a null receiver?
15171517
* In theory, it's UB, but that decision should be left for link time.
15181518
*/
@@ -1522,7 +1522,7 @@ class JSCodeGen()(implicit ctx: Context) {
15221522

15231523
/** Gen JS code for a coercion */
15241524
private def genCoercion(tree: Apply, receiver: Tree, code: Int): js.Tree = {
1525-
implicit val pos = tree.pos
1525+
implicit val pos = tree.span
15261526

15271527
val source = genExpr(receiver)
15281528
val resultType = toIRType(tree.tpe)
@@ -1531,7 +1531,7 @@ class JSCodeGen()(implicit ctx: Context) {
15311531

15321532
/** Gen a call to the special `throw` method. */
15331533
private def genThrow(tree: Apply, args: List[Tree]): js.Tree = {
1534-
implicit val pos = tree.pos
1534+
implicit val pos = tree.span
15351535
val exception = args.head
15361536
val genException = genExpr(exception)
15371537
js.Throw {
@@ -1555,7 +1555,7 @@ class JSCodeGen()(implicit ctx: Context) {
15551555
* * Regular method call
15561556
*/
15571557
private def genNormalApply(tree: Apply, isStat: Boolean): js.Tree = {
1558-
implicit val pos = tree.pos
1558+
implicit val pos = tree.span
15591559

15601560
val fun = tree.fun match {
15611561
case fun: Ident => desugarIdent(fun).get
@@ -1601,7 +1601,7 @@ class JSCodeGen()(implicit ctx: Context) {
16011601
jsSuperClassValue: Option[js.Tree] = None)(
16021602
implicit pos: Position): js.Tree = {
16031603

1604-
implicit val pos = tree.pos
1604+
implicit val pos = tree.span
16051605

16061606
def noSpread = !args.exists(_.isInstanceOf[js.JSSpread])
16071607
val argc = args.size // meaningful only for methods that don't have varargs
@@ -1759,7 +1759,7 @@ class JSCodeGen()(implicit ctx: Context) {
17591759
* primitive instead.)
17601760
*/
17611761
private def genTypeApply(tree: TypeApply): js.Tree = {
1762-
implicit val pos = tree.pos
1762+
implicit val pos = tree.span
17631763

17641764
val TypeApply(fun, targs) = tree
17651765

@@ -1787,7 +1787,7 @@ class JSCodeGen()(implicit ctx: Context) {
17871787

17881788
/** Gen JS code for a Java Seq literal. */
17891789
private def genJavaSeqLiteral(tree: JavaSeqLiteral): js.Tree = {
1790-
implicit val pos = tree.pos
1790+
implicit val pos = tree.span
17911791

17921792
val genElems = tree.elems.map(genExpr)
17931793
val arrayTypeRef = toTypeRef(tree.tpe).asInstanceOf[jstpe.ArrayTypeRef]
@@ -1836,7 +1836,7 @@ class JSCodeGen()(implicit ctx: Context) {
18361836
* available in the `body`.
18371837
*/
18381838
private def genClosure(tree: Closure): js.Tree = {
1839-
implicit val pos = tree.pos
1839+
implicit val pos = tree.span
18401840
val Closure(env, call, functionalInterface) = tree
18411841

18421842
val envSize = env.size
@@ -1852,7 +1852,7 @@ class JSCodeGen()(implicit ctx: Context) {
18521852
val allCaptureValues = qualifier :: env
18531853

18541854
val formalAndActualCaptures = allCaptureValues.map { value =>
1855-
implicit val pos = value.pos
1855+
implicit val pos = value.span
18561856
val formalIdent = value match {
18571857
case Ident(name) => freshLocalIdent(name.toString)
18581858
case This(_) => freshLocalIdent("this")
@@ -1975,7 +1975,7 @@ class JSCodeGen()(implicit ctx: Context) {
19751975

19761976
/** Gen JS code for an isInstanceOf test (for reference types only) */
19771977
private def genIsInstanceOf(tree: Tree, value: js.Tree, to: Type): js.Tree = {
1978-
implicit val pos = tree.pos
1978+
implicit val pos = tree.span
19791979
val sym = to.widenDealias.typeSymbol
19801980

19811981
if (sym == defn.ObjectClass) {
@@ -2193,7 +2193,7 @@ class JSCodeGen()(implicit ctx: Context) {
21932193
* to perform the conversion to js.Array, then wrap in a Spread
21942194
* operator.
21952195
*/
2196-
implicit val pos = arg.pos
2196+
implicit val pos = arg.span
21972197
val jsArrayArg = genModuleApplyMethod(
21982198
jsdefn.Runtime_toJSVarArgs,
21992199
List(genExpr(arg)))
@@ -2210,7 +2210,7 @@ class JSCodeGen()(implicit ctx: Context) {
22102210
*/
22112211
private def tryGenRepeatedParamAsJSArray(arg: Tree,
22122212
handleNil: Boolean): Option[List[js.Tree]] = {
2213-
implicit val pos = arg.pos
2213+
implicit val pos = arg.span
22142214

22152215
// Given a method `def foo(args: T*)`
22162216
arg match {

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

Lines changed: 13 additions & 13 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.sourcePos.withSpan(cdef.namePos))
354+
ctx.error(CaseClassMissingParamList(cdef), cdef.sourcePos.withSpan(cdef.nameSpan))
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.sourcePos.withSpan(cdef.namePos))
357+
ctx.error("Case classes should have a non-implicit parameter list", cdef.sourcePos.withSpan(cdef.nameSpan))
358358
ListOfNil
359359
}
360360
else originalVparamss.nestedMap(toDefParam)
@@ -398,7 +398,7 @@ object desugar {
398398

399399
def appliedTypeTree(tycon: Tree, args: List[Tree]) =
400400
(if (args.isEmpty) tycon else AppliedTypeTree(tycon, args))
401-
.withSpan(cdef.pos.startPos)
401+
.withSpan(cdef.span.startPos)
402402

403403
def isHK(tparam: Tree): Boolean = tparam match {
404404
case TypeDef(_, LambdaTypeTree(tparams, body)) => true
@@ -704,19 +704,19 @@ object desugar {
704704
if (mods is Package)
705705
PackageDef(Ident(moduleName), cpy.ModuleDef(mdef)(nme.PACKAGE, impl).withMods(mods &~ Package) :: Nil)
706706
else if (isEnumCase)
707-
expandEnumModule(moduleName, impl, mods, mdef.pos)
707+
expandEnumModule(moduleName, impl, mods, mdef.span)
708708
else {
709709
val clsName = moduleName.moduleClassName
710710
val clsRef = Ident(clsName)
711711
val modul = ValDef(moduleName, clsRef, New(clsRef, Nil))
712712
.withMods(mods.toTermFlags & RetainedModuleValFlags | ModuleValCreationFlags)
713-
.withSpan(mdef.pos.startPos)
713+
.withSpan(mdef.span.startPos)
714714
val ValDef(selfName, selfTpt, _) = impl.self
715715
val selfMods = impl.self.mods
716716
if (!selfTpt.isEmpty) ctx.error(ObjectMayNotHaveSelfType(mdef), impl.self.sourcePos)
717717
val clsSelf = ValDef(selfName, SingletonTypeTree(Ident(moduleName)), impl.self.rhs)
718718
.withMods(selfMods)
719-
.withSpan(impl.self.pos.orElse(impl.pos.startPos))
719+
.withSpan(impl.self.span.orElse(impl.span.startPos))
720720
val clsTmpl = cpy.Template(impl)(self = clsSelf, body = impl.body)
721721
val cls = TypeDef(clsName, clsTmpl)
722722
.withMods(mods.toTypeFlags & RetainedModuleClassFlags | ModuleClassCreationFlags)
@@ -793,7 +793,7 @@ object desugar {
793793
pats map {
794794
case id: Ident =>
795795
expandSimpleEnumCase(id.name.asTermName, mods,
796-
Span(pdef.pos.start, id.pos.end, id.pos.start))
796+
Span(pdef.span.start, id.span.end, id.span.start))
797797
}
798798
else {
799799
val pats1 = if (tpt.isEmpty) pats else pats map (Typed(_, tpt))
@@ -842,7 +842,7 @@ object desugar {
842842
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal else EmptyFlags)
843843
val firstDef =
844844
ValDef(tmpName, TypeTree(), matchExpr)
845-
.withSpan(pat.pos.union(rhs.pos)).withMods(patMods)
845+
.withSpan(pat.span.union(rhs.span)).withMods(patMods)
846846
def selector(n: Int) = Select(Ident(tmpName), nme.selectorName(n))
847847
val restDefs =
848848
for (((named, tpt), n) <- vars.zipWithIndex)
@@ -879,7 +879,7 @@ object desugar {
879879
def block(tree: Block)(implicit ctx: Context): Block = tree.expr match {
880880
case EmptyTree =>
881881
cpy.Block(tree)(tree.stats,
882-
unitLiteral.withSpan(if (tree.stats.isEmpty) tree.pos else tree.pos.endPos))
882+
unitLiteral.withSpan(if (tree.stats.isEmpty) tree.span else tree.span.endPos))
883883
case _ =>
884884
tree
885885
}
@@ -904,9 +904,9 @@ object desugar {
904904
}
905905

906906
if (isLeftAssoc(op.name))
907-
makeOp(left, right, Span(left.pos.start, op.pos.end, op.pos.start))
907+
makeOp(left, right, Span(left.span.start, op.span.end, op.span.start))
908908
else
909-
makeOp(right, left, Span(op.pos.start, right.pos.end))
909+
makeOp(right, left, Span(op.span.start, right.span.end))
910910
}
911911

912912
/** Translate tuple expressions of arity <= 22
@@ -1020,15 +1020,15 @@ object desugar {
10201020
private def derivedValDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit ctx: Context) = {
10211021
val vdef = ValDef(named.name.asTermName, tpt, rhs)
10221022
.withMods(mods)
1023-
.withSpan(original.pos.withPoint(named.pos.start))
1023+
.withSpan(original.span.withPoint(named.span.start))
10241024
val mayNeedSetter = valDef(vdef)
10251025
mayNeedSetter
10261026
}
10271027

10281028
private def derivedDefDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit src: SourceInfo) =
10291029
DefDef(named.name.asTermName, Nil, Nil, tpt, rhs)
10301030
.withMods(mods)
1031-
.withSpan(original.pos.withPoint(named.pos.start))
1031+
.withSpan(original.span.withPoint(named.span.start))
10321032

10331033
/** Main desugaring method */
10341034
def apply(tree: Tree)(implicit ctx: Context): Tree = {

0 commit comments

Comments
 (0)