Skip to content

Commit 1685473

Browse files
committed
Some trailing Tree refactor changes
1 parent 476bf86 commit 1685473

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ import scala.annotation.tailrec
1616

1717
trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
1818

19-
// Note: the <: Type constraint looks necessary (and is needed to make the file compile in dotc).
20-
// But Scalac accepts the program happily without it. Need to find out why.
21-
2219
def unsplice(tree: Trees.Tree[T]): Trees.Tree[T] = tree
2320

2421
def isDeclarationOrTypeDef(tree: Tree): Boolean = unsplice(tree) match {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ object Trees {
804804
}
805805

806806
/** mods val name: tpt = rhs */
807-
case class ValDef[+T <: Untyped] private[ast] (name: TermName, tpt: Tree[T], private var preRhs: LazyTree[T @uncheckedVariance])(implicit @constructorOnly src: SourceFile)
807+
case class ValDef[+T <: Untyped] private[ast] (name: TermName, tpt: Tree[T], private var preRhs: LazyTree[T])(implicit @constructorOnly src: SourceFile)
808808
extends ValOrDefDef[T], ValOrTypeDef[T] {
809809
type ThisTree[+T <: Untyped] = ValDef[T]
810810
assert(isEmpty || (tpt ne genericEmptyTree))
@@ -814,7 +814,7 @@ object Trees {
814814

815815
/** mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs */
816816
case class DefDef[+T <: Untyped] private[ast] (name: TermName,
817-
paramss: List[ParamClause[T]], tpt: Tree[T], private var preRhs: LazyTree[T @uncheckedVariance])(implicit @constructorOnly src: SourceFile)
817+
paramss: List[ParamClause[T]], tpt: Tree[T], private var preRhs: LazyTree[T])(implicit @constructorOnly src: SourceFile)
818818
extends ValOrDefDef[T] {
819819
type ThisTree[+T <: Untyped] = DefDef[T]
820820
assert(tpt ne genericEmptyTree)
@@ -855,7 +855,7 @@ object Trees {
855855
* if this is of class untpd.DerivingTemplate.
856856
* Typed templates only have parents.
857857
*/
858-
case class Template[+T <: Untyped] private[ast] (constr: DefDef[T], parentsOrDerived: List[Tree[T]], self: ValDef[T], private var preBody: LazyTreeList[T @uncheckedVariance])(implicit @constructorOnly src: SourceFile)
858+
case class Template[+T <: Untyped] private[ast] (constr: DefDef[T], parentsOrDerived: List[Tree[T]], self: ValDef[T], private var preBody: LazyTreeList[T])(implicit @constructorOnly src: SourceFile)
859859
extends DefTree[T] with WithLazyField[List[Tree[T]]] {
860860
type ThisTree[+T <: Untyped] = Template[T]
861861
def unforcedBody: LazyTreeList[T] = unforced
@@ -924,12 +924,12 @@ object Trees {
924924
myTpe = NoType.asInstanceOf[T]
925925
type ThisTree[+T <: Untyped] = Thicket[T]
926926

927-
def mapElems(op: Tree[T] => Tree[T] @uncheckedVariance): Thicket[T] = {
927+
def mapElems[U >: T <: Untyped](op: Tree[T] => Tree[U]): Thicket[U] = {
928928
val newTrees = trees.mapConserve(op)
929929
if (trees eq newTrees)
930930
this
931931
else
932-
Thicket[T](newTrees)(source).asInstanceOf[this.type]
932+
Thicket[U](newTrees)(source).asInstanceOf[this.type]
933933
}
934934

935935
override def foreachInThicket(op: Tree[T] => Unit): Unit =

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ object Contexts {
156156
final def owner: Symbol = _owner
157157

158158
/** The current tree */
159-
private var _tree: Tree[? <: Untyped]= _
160-
protected def tree_=(tree: Tree[? <: Untyped]): Unit = _tree = tree
161-
final def tree: Tree[? <: Untyped] = _tree
159+
private var _tree: Tree[?]= _
160+
protected def tree_=(tree: Tree[?]): Unit = _tree = tree
161+
final def tree: Tree[?] = _tree
162162

163163
/** The current scope */
164164
private var _scope: Scope = _
@@ -469,7 +469,7 @@ object Contexts {
469469
}
470470

471471
/** The context of expression `expr` seen as a member of a statement sequence */
472-
def exprContext(stat: Tree[? <: Untyped], exprOwner: Symbol): Context =
472+
def exprContext(stat: Tree[?], exprOwner: Symbol): Context =
473473
if (exprOwner == this.owner) this
474474
else if (untpd.isSuperConstrCall(stat) && this.owner.isClass) superCallContext
475475
else fresh.setOwner(exprOwner)
@@ -592,7 +592,7 @@ object Contexts {
592592
assert(owner != NoSymbol)
593593
this.owner = owner
594594
this
595-
def setTree(tree: Tree[? <: Untyped]): this.type =
595+
def setTree(tree: Tree[?]): this.type =
596596
util.Stats.record("Context.setTree")
597597
this.tree = tree
598598
this

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
4040

4141
override def printerContext: Context = myCtx
4242

43-
def withEnclosingDef(enclDef: Tree[? <: Untyped])(op: => Text): Text = {
43+
def withEnclosingDef(enclDef: Tree[?])(op: => Text): Text = {
4444
val savedCtx = myCtx
4545
if (enclDef.hasType && enclDef.symbol.exists)
4646
myCtx = ctx.withOwner(enclDef.symbol)
@@ -990,7 +990,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
990990
}
991991

992992
protected def toTextPackageId[T <: Untyped](pid: Tree[T]): Text =
993-
if (homogenizedView && pid.hasType) toTextLocal(pid.tpe.asInstanceOf[Showable])
993+
if (homogenizedView && pid.hasType) toTextLocal(pid.typeOpt)
994994
else toTextLocal(pid)
995995

996996
protected def packageDefText(tree: PackageDef): Text = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ import cc.CaptureSet.IdentityCaptRefMap
13901390
|""".stripMargin
13911391
}
13921392

1393-
class TypeDoesNotTakeParameters(tpe: Type, params: List[Trees.Tree[Trees.Untyped]])(using Context)
1393+
class TypeDoesNotTakeParameters(tpe: Type, params: List[untpd.Tree])(using Context)
13941394
extends TypeMsg(TypeDoesNotTakeParametersID) {
13951395
private def fboundsAddendum =
13961396
if tpe.typeSymbol.isAllOf(Provisional | TypeParam) then

0 commit comments

Comments
 (0)