Skip to content

Commit 07a5d89

Browse files
Devalify: also visitType for New nodes
1 parent de4dd2c commit 07a5d89

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/src/dotty/tools/dotc/transform/linker/Simplify.scala

+7-5
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
245245
case _ => fun
246246
}
247247
val constructor = a.symbol.owner.companionClass.primaryConstructor.asTerm
248-
evalReciever(a, rollInArgs(argss.tail, New(a.tpe.widenDealias, constructor, argss.head)))
248+
rollInArgs(argss.tail, New(a.tpe.widenDealias, constructor, argss.head))
249249

250250
// For synthetic dotty unapplies on case classes:
251251
// - CC.unapply(arg): CC → arg
@@ -1226,9 +1226,11 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
12261226
}
12271227
visitType(valdef.symbol.info)
12281228
case t: New =>
1229-
val symIfExists = t.tpt.tpe.normalizedPrefix.termSymbol
1229+
val normalized = t.tpt.tpe.normalizedPrefix
1230+
val symIfExists = normalized.termSymbol
12301231
val b4 = used.getOrElseUpdate(symIfExists, 0)
12311232
used.put(symIfExists, b4 + 1)
1233+
visitType(normalized)
12321234

12331235
case valdef: ValDef if valdef.symbol.exists && !valdef.symbol.owner.isClass &&
12341236
!valdef.symbol.is(Param | Module | Lazy) =>
@@ -1279,8 +1281,8 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
12791281
// TODO: if a non-synthetic val is duplicate of a synthetic one, rename a synthetic one and drop synthetic flag?
12801282

12811283
val copiesToReplaceAsUsedOnce =
1282-
timesUsed.filter(x => x._2 == 1).
1283-
flatMap(x => copies.get(x._1) match {
1284+
timesUsed.filter(x => x._2 == 1)
1285+
.flatMap(x => copies.get(x._1) match {
12841286
case Some(tr) => List((x._1, tr))
12851287
case None => Nil
12861288
}) -- timesUsedAsType.keySet
@@ -1289,7 +1291,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
12891291

12901292
val deepReplacer = new TreeMap() {
12911293
override def transform(tree: Tree)(implicit ctx: Context): Tree = {
1292-
def loop(tree: Tree):Tree =
1294+
def loop(tree: Tree): Tree =
12931295
tree match {
12941296
case t: RefTree if replacements.contains(t.symbol) =>
12951297
loop(replacements(t.symbol))

0 commit comments

Comments
 (0)