Skip to content

Commit 96c1d22

Browse files
committed
Drop AppliedTypeTree
With the introduction of `Apply` nodes as types, we were facing an imbalance: Type appications distinguished between type trees and term trees by having two classes, `AppliedTypeTree` and `TypeApply`. Term applications did not. In the interest of keeping the number of tree classes low, we now use `TypeApply for both type and term trees that are applied to type tree arguments. The only exception is in the Tasty format, where we need to distinguish the two, because otherwise a hole followed by arguments would be ambiguous. Distinguishing between terms and types in the Tasty serialization format is done systematically everywhere. It has the advantage that it increases redundancy. But for the internal tree representation it's better to have as few classes as possible.
1 parent bc73cd1 commit 96c1d22

24 files changed

+129
-169
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ object desugar {
357357
val classTycon: Tree = new TypeRefTree // watching is set at end of method
358358

359359
def appliedTypeTree(tycon: Tree, args: List[Tree]) =
360-
(if (args.isEmpty) tycon else AppliedTypeTree(tycon, args))
360+
(if (args.isEmpty) tycon else TypeApply(tycon, args))
361361
.withPos(cdef.pos.startPos)
362362

363363
def isHK(tparam: Tree): Boolean = tparam match {
@@ -371,7 +371,7 @@ object desugar {
371371
val targ = refOfDef(tparam)
372372
def fullyApplied(tparam: Tree): Tree = tparam match {
373373
case TypeDef(_, LambdaTypeTree(tparams, body)) =>
374-
AppliedTypeTree(targ, tparams.map(_ => TypeBoundsTree(EmptyTree, EmptyTree)))
374+
TypeApply(targ, tparams.map(_ => TypeBoundsTree(EmptyTree, EmptyTree)))
375375
case TypeDef(_, rhs: DerivedTypeTree) =>
376376
fullyApplied(rhs.watched)
377377
case _ =>
@@ -1113,7 +1113,7 @@ object desugar {
11131113
Apply(Select(Apply(Ident(nme.StringContext), strs), id), elems)
11141114
case InfixOp(l, op, r) =>
11151115
if (ctx.mode is Mode.Type)
1116-
AppliedTypeTree(op, l :: r :: Nil) // op[l, r]
1116+
TypeApply(op, l :: r :: Nil) // op[l, r]
11171117
else {
11181118
assert(ctx.mode is Mode.Pattern) // expressions are handled separately by `binop`
11191119
Apply(op, l :: r :: Nil) // op(l, r)
@@ -1122,7 +1122,7 @@ object desugar {
11221122
if ((ctx.mode is Mode.Type) && !op.isBackquoted && op.name == tpnme.raw.STAR) {
11231123
val seqType = if (ctx.compilationUnit.isJava) defn.ArrayType else defn.SeqType
11241124
Annotated(
1125-
AppliedTypeTree(ref(seqType), t),
1125+
TypeApply(ref(seqType), t :: Nil),
11261126
New(ref(defn.RepeatedAnnotType), Nil :: Nil))
11271127
} else {
11281128
assert(ctx.mode.isExpr || ctx.reporter.hasErrors || ctx.mode.is(Mode.Interactive), ctx.mode)
@@ -1138,7 +1138,7 @@ object desugar {
11381138
ctx.error(TupleTooLong(ts), tree.pos)
11391139
unitLiteral
11401140
} else if (arity == 1) ts.head
1141-
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
1141+
else if (ctx.mode is Mode.Type) TypeApply(ref(tupleTypeRef), ts)
11421142
else if (arity == 0) unitLiteral
11431143
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
11441144
case WhileDo(cond, body) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ object DesugarEnums {
143143

144144
def extractType(t: Tree): Tree = t match {
145145
case Apply(t1, _) => extractType(t1)
146-
case TypeApply(t1, ts) => AppliedTypeTree(extractType(t1), ts)
146+
case TypeApply(t1, ts) => TypeApply(extractType(t1), ts)
147147
case Select(t1, nme.CONSTRUCTOR) => extractType(t1)
148148
case New(t1) => t1
149149
case t1 => t1

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
7272
*/
7373
def methPart(tree: Tree): Tree = stripApply(tree) match {
7474
case TypeApply(fn, _) => methPart(fn)
75-
case AppliedTypeTree(fn, _) => methPart(fn) // !!! should not be needed
7675
case Block(stats, expr) => methPart(expr)
7776
case mp => mp
7877
}
@@ -152,7 +151,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
152151
def isRepeatedParamType(tpt: Tree)(implicit ctx: Context): Boolean = tpt match {
153152
case ByNameTypeTree(tpt1) => isRepeatedParamType(tpt1)
154153
case tpt: TypeTree => tpt.typeOpt.isRepeatedParam
155-
case AppliedTypeTree(Select(_, tpnme.REPEATED_PARAM_CLASS), _) => true
154+
case TypeApply(Select(_, tpnme.REPEATED_PARAM_CLASS), _) => true
156155
case _ => false
157156
}
158157

@@ -164,7 +163,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
164163
case AndTypeTree(tpt1, tpt2) => mayBeTypePat(tpt1) || mayBeTypePat(tpt2)
165164
case OrTypeTree(tpt1, tpt2) => mayBeTypePat(tpt1) || mayBeTypePat(tpt2)
166165
case RefinedTypeTree(tpt, refinements) => mayBeTypePat(tpt) || refinements.exists(_.isInstanceOf[Bind])
167-
case AppliedTypeTree(tpt, args) => mayBeTypePat(tpt) || args.exists(_.isInstanceOf[Bind])
166+
case TypeApply(tpt, args) => mayBeTypePat(tpt) || args.exists(_.isInstanceOf[Bind])
168167
case Select(tpt, _) => mayBeTypePat(tpt)
169168
case Annotated(tpt, _) => mayBeTypePat(tpt)
170169
case _ => false
@@ -578,8 +577,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
578577
loop(fn, targss, args :: argss)
579578
case TypeApply(fn, targs) =>
580579
loop(fn, targs ::: targss, argss)
581-
case AppliedTypeTree(fn, targs) =>
582-
loop(fn, targs ::: targss, argss)
583580
case _ =>
584581
(tree, targss, argss)
585582
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,6 @@ object Trees {
634634
def forwardTo = tpt
635635
}
636636

637-
/** tpt[args] */
638-
case class AppliedTypeTree[-T >: Untyped] private[ast] (tpt: Tree[T], args: List[Tree[T]])
639-
extends ProxyTree[T] with TypTree[T] {
640-
type ThisTree[-T >: Untyped] = AppliedTypeTree[T]
641-
def forwardTo = tpt
642-
}
643-
644637
/** [typeparams] -> tpt */
645638
case class LambdaTypeTree[-T >: Untyped] private[ast] (tparams: List[TypeDef[T]], body: Tree[T])
646639
extends TypTree[T] {
@@ -898,7 +891,6 @@ object Trees {
898891
type AndTypeTree = Trees.AndTypeTree[T]
899892
type OrTypeTree = Trees.OrTypeTree[T]
900893
type RefinedTypeTree = Trees.RefinedTypeTree[T]
901-
type AppliedTypeTree = Trees.AppliedTypeTree[T]
902894
type LambdaTypeTree = Trees.LambdaTypeTree[T]
903895
type ByNameTypeTree = Trees.ByNameTypeTree[T]
904896
type TypeBoundsTree = Trees.TypeBoundsTree[T]
@@ -1060,10 +1052,6 @@ object Trees {
10601052
case tree: RefinedTypeTree if (tpt eq tree.tpt) && (refinements eq tree.refinements) => tree
10611053
case _ => finalize(tree, untpd.RefinedTypeTree(tpt, refinements))
10621054
}
1063-
def AppliedTypeTree(tree: Tree)(tpt: Tree, args: List[Tree]): AppliedTypeTree = tree match {
1064-
case tree: AppliedTypeTree if (tpt eq tree.tpt) && (args eq tree.args) => tree
1065-
case _ => finalize(tree, untpd.AppliedTypeTree(tpt, args))
1066-
}
10671055
def LambdaTypeTree(tree: Tree)(tparams: List[TypeDef], body: Tree): LambdaTypeTree = tree match {
10681056
case tree: LambdaTypeTree if (tparams eq tree.tparams) && (body eq tree.body) => tree
10691057
case _ => finalize(tree, untpd.LambdaTypeTree(tparams, body))
@@ -1217,8 +1205,6 @@ object Trees {
12171205
cpy.OrTypeTree(tree)(transform(left), transform(right))
12181206
case RefinedTypeTree(tpt, refinements) =>
12191207
cpy.RefinedTypeTree(tree)(transform(tpt), transformSub(refinements))
1220-
case AppliedTypeTree(tpt, args) =>
1221-
cpy.AppliedTypeTree(tree)(transform(tpt), transform(args))
12221208
case LambdaTypeTree(tparams, body) =>
12231209
implicit val ctx = localCtx
12241210
cpy.LambdaTypeTree(tree)(transformSub(tparams), transform(body))
@@ -1349,8 +1335,6 @@ object Trees {
13491335
this(this(x, left), right)
13501336
case RefinedTypeTree(tpt, refinements) =>
13511337
this(this(x, tpt), refinements)
1352-
case AppliedTypeTree(tpt, args) =>
1353-
this(this(x, tpt), args)
13541338
case LambdaTypeTree(tparams, body) =>
13551339
implicit val ctx = localCtx
13561340
this(this(x, tparams), body)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
148148
def RefinedTypeTree(parent: Tree, refinements: List[Tree], refineCls: ClassSymbol)(implicit ctx: Context): Tree =
149149
ta.assignType(untpd.RefinedTypeTree(parent, refinements), parent, refinements, refineCls)
150150

151-
def AppliedTypeTree(tycon: Tree, args: List[Tree])(implicit ctx: Context): AppliedTypeTree =
152-
ta.assignType(untpd.AppliedTypeTree(tycon, args), tycon, args)
153-
154151
def ByNameTypeTree(result: Tree)(implicit ctx: Context): ByNameTypeTree =
155152
ta.assignType(untpd.ByNameTypeTree(result), result)
156153

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
286286
def AndTypeTree(left: Tree, right: Tree): AndTypeTree = new AndTypeTree(left, right)
287287
def OrTypeTree(left: Tree, right: Tree): OrTypeTree = new OrTypeTree(left, right)
288288
def RefinedTypeTree(tpt: Tree, refinements: List[Tree]): RefinedTypeTree = new RefinedTypeTree(tpt, refinements)
289-
def AppliedTypeTree(tpt: Tree, args: List[Tree]): AppliedTypeTree = new AppliedTypeTree(tpt, args)
290289
def LambdaTypeTree(tparams: List[TypeDef], body: Tree): LambdaTypeTree = new LambdaTypeTree(tparams, body)
291290
def ByNameTypeTree(result: Tree): ByNameTypeTree = new ByNameTypeTree(result)
292291
def TypeBoundsTree(lo: Tree, hi: Tree): TypeBoundsTree = new TypeBoundsTree(lo, hi)
@@ -309,9 +308,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
309308
*/
310309
def New(tpt: Tree, argss: List[List[Tree]])(implicit ctx: Context): Tree = {
311310
val (tycon, targs) = tpt match {
312-
case AppliedTypeTree(tycon, targs) =>
311+
case TypeApply(tycon, targs) =>
313312
(tycon, targs)
314-
case TypedSplice(AppliedTypeTree(tycon, targs)) =>
313+
case TypedSplice(TypeApply(tycon, targs)) =>
315314
(TypedSplice(tycon), targs map (TypedSplice(_)))
316315
case TypedSplice(tpt1: tpd.Tree) =>
317316
val tycon = tpt1.tpe.typeConstructor
@@ -337,9 +336,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
337336
case _ => Apply(tpt, Nil)
338337
}
339338

340-
def AppliedTypeTree(tpt: Tree, arg: Tree): AppliedTypeTree =
341-
AppliedTypeTree(tpt, arg :: Nil)
342-
343339
def TypeTree(tpe: Type)(implicit ctx: Context): TypedSplice = TypedSplice(TypeTree().withTypeUnchecked(tpe))
344340

345341
def unitLiteral = Literal(Constant(()))

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ object StdNames {
324324
// Compiler utilized names
325325

326326
val AnnotatedType: N = "AnnotatedType"
327-
val AppliedTypeTree: N = "AppliedTypeTree"
328327
val ArrayAnnotArg: N = "ArrayAnnotArg"
329328
val Constant: N = "Constant"
330329
val ConstantType: N = "ConstantType"

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,7 @@ class TreePickler(pickler: TastyPickler) {
373373
}
374374
case TypeApply(fun, args) =>
375375
writeByte(if (tree.isType) TYPEAPPLYtpt else TYPEAPPLY)
376-
withLength {
377-
pickleTree(fun)
378-
args.foreach(pickleTpt)
379-
}
376+
withLength { pickleTree(fun); args.foreach(pickleTpt) }
380377
case Literal(const1) =>
381378
pickleConstant {
382379
tree.tpe match {
@@ -523,9 +520,6 @@ class TreePickler(pickler: TastyPickler) {
523520
refinements.foreach(preRegister)
524521
withLength { pickleTree(parent); refinements.foreach(pickleTree) }
525522
}
526-
case AppliedTypeTree(tycon, args) =>
527-
writeByte(TYPEAPPLYtpt)
528-
withLength { pickleTree(tycon); args.foreach(pickleTree) }
529523
case AndTypeTree(tp1, tp2) =>
530524
writeByte(ANDtpt)
531525
withLength { pickleTree(tp1); pickleTree(tp2) }
@@ -818,9 +812,6 @@ class TreePickler(pickler: TastyPickler) {
818812
case RefinedTypeTree(parent, refinements) =>
819813
writeByte(REFINEDtpt)
820814
withLength { pickleTpt(parent); refinements.foreach(pickleTerm) }
821-
case AppliedTypeTree(tycon, args) =>
822-
writeByte(TYPEAPPLYtpt)
823-
withLength { pickleTpt(tycon); args.foreach(pickleTpt) }
824815
case AndTypeTree(tp1, tp2) =>
825816
writeByte(ANDtpt)
826817
withLength { pickleTpt(tp1); pickleTpt(tp2) }

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ class TreeUnpickler(reader: TastyReader,
11311131
// types. This came up in #137 of collection strawman.
11321132
val tycon = readTpt()
11331133
val args = until(end)(readTpt())
1134-
untpd.AppliedTypeTree(tycon, args).withType(tycon.tpe.safeAppliedTo(args.tpes))
1134+
untpd.TypeApply(tycon, args).withType(tycon.tpe.safeAppliedTo(args.tpes))
11351135
case ANDtpt =>
11361136
val tpt1 = readTpt()
11371137
val tpt2 = readTpt()
@@ -1376,8 +1376,6 @@ class TreeUnpickler(reader: TastyReader,
13761376
untpd.Import(readUntyped(), readSelectors())
13771377
case REFINEDtpt =>
13781378
untpd.RefinedTypeTree(readUntyped(), until(end)(readUntyped()))
1379-
case TYPEAPPLYtpt =>
1380-
untpd.AppliedTypeTree(readUntyped(), until(end)(readUntyped()))
13811379
case ANDtpt =>
13821380
untpd.AndTypeTree(readUntyped(), readUntyped())
13831381
case ORtpt =>

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
12101210
case APPLIEDTYPEtree =>
12111211
val tpt = readTreeRef()
12121212
val args = until(end, () => readTreeRef())
1213-
AppliedTypeTree(tpt, args)
1213+
TypeApply(tpt, args)
12141214

12151215
case TYPEBOUNDStree =>
12161216
val lo = readTreeRef()

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object JavaParsers {
105105
def javaLangObject(): Tree = javaLangDot(tpnme.Object)
106106

107107
def arrayOf(tpt: Tree) =
108-
AppliedTypeTree(Ident(nme.Array.toTypeName), List(tpt))
108+
TypeApply(Ident(nme.Array.toTypeName), List(tpt))
109109

110110
def unimplementedExpr(implicit ctx: Context) =
111111
Select(Select(rootDot(nme.scala_), nme.Predef), nme.???)
@@ -230,7 +230,7 @@ object JavaParsers {
230230
def convertToTypeId(tree: Tree): Tree = convertToTypeName(tree) match {
231231
case Some(t) => t withPos tree.pos
232232
case _ => tree match {
233-
case AppliedTypeTree(_, _) | Select(_, _) =>
233+
case TypeApply(_, _) | Select(_, _) =>
234234
tree
235235
case _ =>
236236
syntaxError(IdentifierExpected(tree.show), tree.pos)
@@ -327,7 +327,7 @@ object JavaParsers {
327327
val args = repsep(() => typeArg(), COMMA)
328328
acceptClosingAngle()
329329
atPos(t1.pos.start) {
330-
AppliedTypeTree(t1, args)
330+
TypeApply(t1, args)
331331
}
332332
} else t
333333
}
@@ -835,7 +835,7 @@ object JavaParsers {
835835
accept(RBRACE)
836836
/*
837837
val superclazz =
838-
AppliedTypeTree(javaLangDot(tpnme.Enum), List(enumType))
838+
TypeApply(javaLangDot(tpnme.Enum), List(enumType))
839839
*/
840840
val superclazz = Apply(TypeApply(
841841
Select(New(javaLangDot(tpnme.Enum)), nme.CONSTRUCTOR), List(enumType)),

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ object Parsers {
901901
private def simpleTypeRest(t: Tree): Tree = in.token match {
902902
case HASH => simpleTypeRest(typeProjection(t))
903903
case LBRACKET => simpleTypeRest(atPos(startOffset(t)) {
904-
AppliedTypeTree(checkWildcard(t), typeArgs(namedOK = false, wildOK = true)) })
904+
TypeApply(checkWildcard(t), typeArgs(namedOK = false, wildOK = true)) })
905905
case _ => t
906906
}
907907

@@ -996,7 +996,7 @@ object Parsers {
996996
def contextBounds(pname: TypeName): List[Tree] = in.token match {
997997
case COLON =>
998998
atPos(in.skipToken()) {
999-
AppliedTypeTree(toplevelTyp(), Ident(pname))
999+
TypeApply(toplevelTyp(), Ident(pname) :: Nil)
10001000
} :: contextBounds(pname)
10011001
case VIEWBOUND =>
10021002
deprecationWarning("view bounds `<%' are deprecated, use a context bound `:' instead")

compiler/src/dotty/tools/dotc/parsing/ScriptParsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ object ScriptParsers {
127127
)
128128
129129
// def main
130-
def mainParamType = AppliedTypeTree(Ident(tpnme.Array), List(Ident(tpnme.String)))
130+
def mainParamType = TypeApply(Ident(tpnme.Array), List(Ident(tpnme.String)))
131131
def mainParameter = List(ValDef(Modifiers(Param), "argv", mainParamType, EmptyTree))
132132
def mainSetArgv = List(ValDef(Modifiers(), "args", TypeTree(), Ident("argv")))
133133
def mainNew = makeNew(Nil, emptyValDef, stmts, List(Nil), NoPosition, NoPosition)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
261261
changePrec(GlobalPrec) { keywordStr("for ") ~ Text(enums map enumText, "; ") ~ sep ~ toText(expr) }
262262

263263
def cxBoundToText(bound: untpd.Tree): Text = bound match { // DD
264-
case AppliedTypeTree(tpt, _) => " : " ~ toText(tpt)
264+
case TypeApply(tpt, _) => " : " ~ toText(tpt)
265265
case untpd.Function(_, tpt) => " <% " ~ toText(tpt)
266266
}
267267

@@ -379,8 +379,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
379379
changePrec(OrPrec) { toText(l) ~ " | " ~ toText(r) }
380380
case RefinedTypeTree(tpt, refines) =>
381381
toTextLocal(tpt) ~ " " ~ blockText(refines)
382-
case AppliedTypeTree(tpt, args) =>
383-
toTextLocal(tpt) ~ "[" ~ Text(args map argText, ", ") ~ "]"
384382
case LambdaTypeTree(tparams, body) =>
385383
changePrec(GlobalPrec) {
386384
tparamsText(tparams) ~ " -> " ~ toText(body)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s
669669

670670
object Applied extends AppliedExtractor {
671671
def unapply(x: TypeTree)(implicit ctx: Context): Option[(TypeTree, List[TypeOrBoundsTree])] = x match {
672-
case x: tpd.AppliedTypeTree @unchecked => Some(x.tpt, x.args)
672+
case x: tpd.TypeApply @unchecked => Some(x.fun, x.args)
673673
case _ => None
674674
}
675675
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
153153
if (tree.isType) toTypeTree(tree) else constToLiteral(tree)
154154

155155
override def transformTypeApply(tree: TypeApply)(implicit ctx: Context) =
156-
constToLiteral(tree)
156+
if (tree.isType) toTypeTree(tree) else constToLiteral(tree)
157157

158158
override def transformApply(tree: Apply)(implicit ctx: Context) =
159-
constToLiteral(foldCondition(tree))
159+
if (tree.isType) toTypeTree(tree) else constToLiteral(foldCondition(tree))
160160

161161
override def transformTyped(tree: Typed)(implicit ctx: Context) =
162162
constToLiteral(tree)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class LinkAll extends Phase {
4444
private[this] var inParents = false
4545
override def apply(acc: Set[ClassDenotation], tree: tpd.Tree)(implicit ctx: Context): Set[ClassDenotation] = tree match {
4646
case New(tpt) => accum(acc, tpt.tpe.classSymbol)
47-
case AppliedTypeTree(tpt, _) if inParents => accum(acc, tpt.symbol)
47+
case TypeApply(tpt, _) if tpt.isType && inParents => accum(acc, tpt.symbol)
4848
case tree: RefTree if inParents || tree.symbol.is(Module) =>
4949
foldOver(accum(acc, tree.symbol), tree)
5050
case tree @ Template(constr, parents, self, _) =>

0 commit comments

Comments
 (0)