@@ -7,7 +7,7 @@ import dotty.tools.dotc.core.Symbols.NoSymbol
7
7
import dotty .tools .dotc .core ._
8
8
import dotty .tools .dotc .tastyreflect .FromSymbol .{definitionFromSym , packageDefFromSym }
9
9
10
- trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers {
10
+ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with Helpers {
11
11
12
12
def TreeDeco (tree : Tree ): TreeAPI = new TreeAPI {
13
13
def pos (implicit ctx : Context ): Position = tree.sourcePos
@@ -190,7 +190,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
190
190
191
191
object PackageClause extends PackageClauseModule {
192
192
def apply (pid : Term .Ref , stats : List [Tree ])(implicit ctx : Context ): PackageClause =
193
- tpd.PackageDef (pid.asInstanceOf [tpd.RefTree ], stats)
193
+ withDefaultPos(ctx => tpd.PackageDef (pid.asInstanceOf [tpd.RefTree ], stats)(ctx) )
194
194
195
195
def copy (original : PackageClause )(pid : Term .Ref , stats : List [Tree ])(implicit ctx : Context ): PackageClause =
196
196
tpd.cpy.PackageDef (original)(pid, stats)
@@ -210,7 +210,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
210
210
211
211
object Import extends ImportModule {
212
212
def apply (impliedOnly : Boolean , expr : Term , selectors : List [ImportSelector ])(implicit ctx : Context ): Import =
213
- tpd.Import (impliedOnly, expr, selectors)
213
+ withDefaultPos(ctx => tpd.Import (impliedOnly, expr, selectors)(ctx) )
214
214
215
215
def copy (original : Import )(impliedOnly : Boolean , expr : Term , selectors : List [ImportSelector ])(implicit ctx : Context ): Import =
216
216
tpd.cpy.Import (original)(impliedOnly, expr, selectors)
@@ -276,7 +276,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
276
276
277
277
object DefDef extends DefDefModule {
278
278
def apply (symbol : DefSymbol , rhsFn : List [Type ] => List [List [Term ]] => Option [Term ])(implicit ctx : Context ): DefDef =
279
- tpd.polyDefDef(symbol, tparams => vparamss => rhsFn(tparams)(vparamss).getOrElse(tpd.EmptyTree ))
279
+ withDefaultPos(ctx => tpd.polyDefDef(symbol, tparams => vparamss => rhsFn(tparams)(vparamss).getOrElse(tpd.EmptyTree ))(ctx ))
280
280
281
281
def copy (original : DefDef )(name : String , typeParams : List [TypeDef ], paramss : List [List [ValDef ]], tpt : TypeTree , rhs : Option [Term ])(implicit ctx : Context ): DefDef =
282
282
tpd.cpy.DefDef (original)(name.toTermName, typeParams, paramss, tpt, rhs.getOrElse(tpd.EmptyTree ))
@@ -323,7 +323,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
323
323
}
324
324
325
325
object TypeDef extends TypeDefModule {
326
- def apply (symbol : TypeSymbol )(implicit ctx : Context ): TypeDef = tpd.TypeDef (symbol)
326
+ def apply (symbol : TypeSymbol )(implicit ctx : Context ): TypeDef = withDefaultPos(ctx => tpd.TypeDef (symbol)(ctx) )
327
327
def copy (original : TypeDef )(name : String , rhs : TypeOrBoundsTree )(implicit ctx : Context ): TypeDef =
328
328
tpd.cpy.TypeDef (original)(name.toTypeName, rhs)
329
329
def unapply (tree : Tree )(implicit ctx : Context ): Option [(String , TypeOrBoundsTree /* TypeTree | TypeBoundsTree */ )] = tree match {
@@ -379,7 +379,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
379
379
380
380
381
381
object Ref extends RefModule {
382
- def apply (sym : Symbol )(implicit ctx : Context ): Ref = tpd.ref(sym).asInstanceOf [tpd.RefTree ]
382
+ def apply (sym : Symbol )(implicit ctx : Context ): Ref = withDefaultPos(ctx => tpd.ref(sym)(ctx) .asInstanceOf [tpd.RefTree ])
383
383
}
384
384
385
385
object Ident extends IdentModule {
@@ -422,7 +422,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
422
422
object Literal extends LiteralModule {
423
423
424
424
def apply (constant : Constant )(implicit ctx : Context ): Literal =
425
- tpd.Literal (constant)
425
+ withDefaultPos(ctx => tpd.Literal (constant)(ctx) )
426
426
427
427
def copy (original : Tree )(constant : Constant )(implicit ctx : Context ): Literal =
428
428
tpd.cpy.Literal (original)(constant)
@@ -444,7 +444,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
444
444
object This extends ThisModule {
445
445
446
446
def apply (cls : ClassSymbol )(implicit ctx : Context ): This =
447
- tpd.This (cls)
447
+ withDefaultPos(ctx => tpd.This (cls)(ctx) )
448
448
449
449
def copy (original : Tree )(qual : Option [Id ])(implicit ctx : Context ): This =
450
450
tpd.cpy.This (original)(qual.getOrElse(untpd.EmptyTypeIdent ))
@@ -464,7 +464,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
464
464
465
465
object New extends NewModule {
466
466
467
- def apply (tpt : TypeTree )(implicit ctx : Context ): New = tpd.New (tpt)
467
+ def apply (tpt : TypeTree )(implicit ctx : Context ): New = withDefaultPos(ctx => tpd.New (tpt)(ctx) )
468
468
469
469
def copy (original : Tree )(tpt : TypeTree )(implicit ctx : Context ): New =
470
470
tpd.cpy.New (original)(tpt)
@@ -490,7 +490,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
490
490
object NamedArg extends NamedArgModule {
491
491
492
492
def apply (name : String , arg : Term )(implicit ctx : Context ): NamedArg =
493
- tpd.NamedArg (name.toTermName, arg)
493
+ withDefaultPos(ctx => tpd.NamedArg (name.toTermName, arg)(ctx) )
494
494
495
495
def copy (tree : NamedArg )(name : String , arg : Term )(implicit ctx : Context ): NamedArg =
496
496
tpd.cpy.NamedArg (tree)(name.toTermName, arg)
@@ -512,7 +512,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
512
512
object Apply extends ApplyModule {
513
513
514
514
def apply (fn : Term , args : List [Term ])(implicit ctx : Context ): Apply =
515
- tpd.Apply (fn, args)
515
+ withDefaultPos(ctx => tpd.Apply (fn, args)(ctx) )
516
516
517
517
def copy (original : Tree )(fun : Term , args : List [Term ])(implicit ctx : Context ): Apply =
518
518
tpd.cpy.Apply (original)(fun, args)
@@ -534,7 +534,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
534
534
object TypeApply extends TypeApplyModule {
535
535
536
536
def apply (fn : Term , args : List [TypeTree ])(implicit ctx : Context ): TypeApply =
537
- tpd.TypeApply (fn, args)
537
+ withDefaultPos(ctx => tpd.TypeApply (fn, args)(ctx) )
538
538
539
539
def copy (original : Tree )(fun : Term , args : List [TypeTree ])(implicit ctx : Context ): TypeApply =
540
540
tpd.cpy.TypeApply (original)(fun, args)
@@ -555,7 +555,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
555
555
556
556
object Super extends SuperModule {
557
557
def apply (qual : Term , mix : Option [Id ])(implicit ctx : Context ): Super =
558
- tpd.Super (qual, mix.getOrElse(untpd.EmptyTypeIdent ), false , NoSymbol )
558
+ withDefaultPos(ctx => tpd.Super (qual, mix.getOrElse(untpd.EmptyTypeIdent ), false , NoSymbol )(ctx) )
559
559
560
560
def copy (original : Tree )(qual : Term , mix : Option [Id ])(implicit ctx : Context ): Super =
561
561
tpd.cpy.Super (original)(qual, mix.getOrElse(untpd.EmptyTypeIdent ))
@@ -576,7 +576,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
576
576
577
577
object Typed extends TypedModule {
578
578
def apply (expr : Term , tpt : TypeTree )(implicit ctx : Context ): Typed =
579
- tpd.Typed (expr, tpt)
579
+ withDefaultPos(ctx => tpd.Typed (expr, tpt)(ctx) )
580
580
581
581
def copy (original : Tree )(expr : Term , tpt : TypeTree )(implicit ctx : Context ): Typed =
582
582
tpd.cpy.Typed (original)(expr, tpt)
@@ -597,7 +597,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
597
597
598
598
object Assign extends AssignModule {
599
599
def apply (lhs : Term , rhs : Term )(implicit ctx : Context ): Assign =
600
- tpd.Assign (lhs, rhs)
600
+ withDefaultPos(ctx => tpd.Assign (lhs, rhs)(ctx) )
601
601
602
602
def copy (original : Tree )(lhs : Term , rhs : Term )(implicit ctx : Context ): Assign =
603
603
tpd.cpy.Assign (original)(lhs, rhs)
@@ -647,7 +647,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
647
647
648
648
object Block extends BlockModule {
649
649
def apply (stats : List [Statement ], expr : Term )(implicit ctx : Context ): Block =
650
- tpd.Block (stats, expr)
650
+ withDefaultPos(ctx => tpd.Block (stats, expr)(ctx) )
651
651
652
652
def copy (original : Tree )(stats : List [Statement ], expr : Term )(implicit ctx : Context ): Block =
653
653
tpd.cpy.Block (original)(stats, expr)
@@ -668,7 +668,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
668
668
669
669
object Inlined extends InlinedModule {
670
670
def apply (call : Option [TermOrTypeTree ], bindings : List [Definition ], expansion : Term )(implicit ctx : Context ): Inlined =
671
- tpd.Inlined (call.getOrElse(tpd.EmptyTree ), bindings.map { case b : tpd.MemberDef => b }, expansion)
671
+ withDefaultPos(ctx => tpd.Inlined (call.getOrElse(tpd.EmptyTree ), bindings.map { case b : tpd.MemberDef => b }, expansion)(ctx) )
672
672
673
673
def copy (original : Tree )(call : Option [TermOrTypeTree ], bindings : List [Definition ], expansion : Term )(implicit ctx : Context ): Inlined =
674
674
tpd.cpy.Inlined (original)(call.getOrElse(tpd.EmptyTree ), bindings.asInstanceOf [List [tpd.MemberDef ]], expansion)
@@ -690,7 +690,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
690
690
691
691
object Lambda extends LambdaModule {
692
692
def apply (meth : Term , tpt : Option [TypeTree ])(implicit ctx : Context ): Lambda =
693
- tpd.Closure (Nil , meth, tpt.getOrElse(tpd.EmptyTree ))
693
+ withDefaultPos(ctx => tpd.Closure (Nil , meth, tpt.getOrElse(tpd.EmptyTree ))(ctx ))
694
694
695
695
def copy (original : Tree )(meth : Tree , tpt : Option [TypeTree ])(implicit ctx : Context ): Lambda =
696
696
tpd.cpy.Closure (original)(Nil , meth, tpt.getOrElse(tpd.EmptyTree ))
@@ -711,7 +711,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
711
711
712
712
object If extends IfModule {
713
713
def apply (cond : Term , thenp : Term , elsep : Term )(implicit ctx : Context ): If =
714
- tpd.If (cond, thenp, elsep)
714
+ withDefaultPos(ctx => tpd.If (cond, thenp, elsep)(ctx) )
715
715
716
716
def copy (original : Tree )(cond : Term , thenp : Term , elsep : Term )(implicit ctx : Context ): If =
717
717
tpd.cpy.If (original)(cond, thenp, elsep)
@@ -732,7 +732,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
732
732
733
733
object Match extends MatchModule {
734
734
def apply (selector : Term , cases : List [CaseDef ])(implicit ctx : Context ): Match =
735
- tpd.Match (selector, cases)
735
+ withDefaultPos(ctx => tpd.Match (selector, cases)(ctx) )
736
736
737
737
def copy (original : Tree )(selector : Term , cases : List [CaseDef ])(implicit ctx : Context ): Match =
738
738
tpd.cpy.Match (original)(selector, cases)
@@ -753,7 +753,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
753
753
754
754
object Try extends TryModule {
755
755
def apply (expr : Term , cases : List [CaseDef ], finalizer : Option [Term ])(implicit ctx : Context ): Try =
756
- tpd.Try (expr, cases, finalizer.getOrElse(tpd.EmptyTree ))
756
+ withDefaultPos(ctx => tpd.Try (expr, cases, finalizer.getOrElse(tpd.EmptyTree ))(ctx ))
757
757
758
758
def copy (original : Tree )(expr : Term , cases : List [CaseDef ], finalizer : Option [Term ])(implicit ctx : Context ): Try =
759
759
tpd.cpy.Try (original)(expr, cases, finalizer.getOrElse(tpd.EmptyTree ))
@@ -774,7 +774,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
774
774
775
775
object Return extends ReturnModule {
776
776
def apply (expr : Term )(implicit ctx : Context ): Return =
777
- tpd.Return (expr, ctx.owner)
777
+ withDefaultPos(ctx => tpd.Return (expr, ctx.owner)(ctx) )
778
778
779
779
def copy (original : Tree )(expr : Term )(implicit ctx : Context ): Return =
780
780
tpd.cpy.Return (original)(expr, tpd.ref(ctx.owner))
@@ -795,7 +795,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
795
795
796
796
object Repeated extends RepeatedModule {
797
797
def apply (elems : List [Term ], elemtpt : TypeTree )(implicit ctx : Context ): Repeated =
798
- tpd.SeqLiteral (elems, elemtpt)
798
+ withDefaultPos(ctx => tpd.SeqLiteral (elems, elemtpt)(ctx) )
799
799
800
800
def copy (original : Tree )(elems : List [Term ], elemtpt : TypeTree )(implicit ctx : Context ): Repeated =
801
801
tpd.cpy.SeqLiteral (original)(elems, elemtpt)
@@ -821,7 +821,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
821
821
object SelectOuter extends SelectOuterModule {
822
822
823
823
def apply (qualifier : Term , name : String , levels : Int )(implicit ctx : Context ): SelectOuter =
824
- tpd.Select (qualifier, NameKinds .OuterSelectName (name.toTermName, levels))
824
+ withDefaultPos(ctx => tpd.Select (qualifier, NameKinds .OuterSelectName (name.toTermName, levels))(ctx ))
825
825
826
826
def copy (original : Tree )(qualifier : Term , name : String , levels : Int )(implicit ctx : Context ): SelectOuter =
827
827
tpd.cpy.Select (original)(qualifier, NameKinds .OuterSelectName (name.toTermName, levels))
@@ -846,7 +846,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
846
846
847
847
object While extends WhileModule {
848
848
def apply (cond : Term , body : Term )(implicit ctx : Context ): While =
849
- tpd.WhileDo (cond, body)
849
+ withDefaultPos(ctx => tpd.WhileDo (cond, body)(ctx) )
850
850
851
851
def copy (original : Tree )(cond : Term , body : Term )(implicit ctx : Context ): While =
852
852
tpd.cpy.WhileDo (original)(cond, body)
@@ -859,4 +859,5 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with CoreImpl with Helpers
859
859
}
860
860
861
861
def termAsTermOrTypeTree (term : Term ): TermOrTypeTree = term
862
+
862
863
}
0 commit comments