Skip to content

Commit 1db601a

Browse files
committed
Remove dead code
We never call `add` on traits as ensured by `takesBridges`
1 parent 0353e64 commit 1db601a

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,13 @@ class Bridges(root: ClassSymbol)(implicit ctx: Context) {
104104
/** Add all necessary bridges to template statements `stats`, and remove at the same
105105
* time deferred methods in `stats` that are replaced by a bridge with the same signature.
106106
*/
107-
def add(stats: List[untpd.Tree]): List[untpd.Tree] =
108-
if (root.is(Trait)) stats
109-
else {
110-
val opc = new BridgesCursor()(preErasureCtx)
111-
while (opc.hasNext) {
112-
if (!opc.overriding.is(Deferred)) addBridgeIfNeeded(opc.overriding, opc.overridden)
113-
opc.next()
114-
}
115-
if (bridges.isEmpty) stats
116-
else stats.filterNot(stat => toBeRemoved contains stat.symbol) ::: bridges.toList
107+
def add(stats: List[untpd.Tree]): List[untpd.Tree] = {
108+
val opc = new BridgesCursor()(preErasureCtx)
109+
while (opc.hasNext) {
110+
if (!opc.overriding.is(Deferred)) addBridgeIfNeeded(opc.overriding, opc.overridden)
111+
opc.next()
117112
}
118-
}
113+
if (bridges.isEmpty) stats
114+
else stats.filterNot(stat => toBeRemoved contains stat.symbol) ::: bridges.toList
115+
}
116+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ object Erasure {
665665
}
666666
}
667667

668-
override def typedTypeDef(tdef: untpd.TypeDef, sym: Symbol)(implicit ctx: Context) =
668+
override def typedTypeDef(tdef: untpd.TypeDef, sym: Symbol)(implicit ctx: Context): Tree =
669669
EmptyTree
670670

671671
override def typedStats(stats: List[untpd.Tree], exprOwner: Symbol)(implicit ctx: Context): List[Tree] = {
@@ -684,8 +684,8 @@ object Erasure {
684684
}
685685

686686
override def simplify(tree: Tree, pt: Type, locked: TypeVars)(implicit ctx: Context): tree.type = tree
687-
}
687+
}
688688

689-
def takesBridges(sym: Symbol)(implicit ctx: Context) =
689+
private def takesBridges(sym: Symbol)(implicit ctx: Context): Boolean =
690690
sym.isClass && !sym.is(Flags.Trait | Flags.Package)
691691
}

0 commit comments

Comments
 (0)