File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -743,6 +743,8 @@ object Symbols {
743
743
def keysIterator : Iterator [Symbol ] = value.keySet().asScala.iterator
744
744
745
745
def toMap : Map [Symbol , T ] = value.asScala.toMap
746
+
747
+ override def toString : String = value.asScala.toString()
746
748
}
747
749
748
750
@ inline def newMutableSymbolMap [T ]: MutableSymbolMap [T ] =
Original file line number Diff line number Diff line change @@ -159,6 +159,9 @@ class Devalify extends Optimisation {
159
159
if (replacements.contains(t.symbol))
160
160
deepReplacer.transform(replacements(t.symbol)).ensureConforms(t.tpe.widen)
161
161
else t
162
+ case t : DefDef if timesUsed.getOrElse(t.symbol, 0 ) == 0 =>
163
+ simplify.println(s " Dropping definition of ${t.symbol.showFullName} as not used " )
164
+ EmptyTree
162
165
case tree => tree
163
166
}
164
167
Original file line number Diff line number Diff line change @@ -164,6 +164,16 @@ abstract class SimplifyTests(val optimise: Boolean) extends DottyBytecodeTest {
164
164
|print(8)
165
165
""" )
166
166
167
+ @ Test def localDefinitionElimination =
168
+ check(
169
+ """
170
+ |lazy val foo = 1
171
+ |def bar = 2
172
+ |val baz = 3
173
+ """ ,
174
+ """
175
+ """ )
176
+
167
177
// @Test def listPatmapExample =
168
178
// check(
169
179
// """
You can’t perform that action at this time.
0 commit comments