1
1
package dotty .tools .dotc .transform
2
2
3
- import scala .annotation .tailrec
3
+ import scala .annotation .*
4
4
5
5
import dotty .tools .uncheckedNN
6
6
import dotty .tools .dotc .ast .tpd .*
@@ -301,7 +301,7 @@ object CheckUnused:
301
301
*
302
302
* For other contexts, which symbols defined here have been referenced?
303
303
*/
304
- private class UnusedData :
304
+ private class UnusedData ( using Context @ constructorOnly) :
305
305
import collection .mutable as mut , mut .Stack , mut .ListBuffer
306
306
import UnusedData .*
307
307
@@ -330,8 +330,13 @@ object CheckUnused:
330
330
331
331
/** All used symbols */
332
332
private val usedDef = mut.Set .empty[Symbol ]
333
- /** Do not register as used */
334
- private val doNotRegister = mut.Set .empty[Symbol ]
333
+
334
+ /** Do not register as used.
335
+ *
336
+ * Seed with common symbols that are never warnable, as an optimization.
337
+ */
338
+ private val doNotRegister = mut.Set [Symbol ](defn.SourceFileAnnot , defn.ModuleSerializationProxyClass )
339
+ private val doNotRegisterPrefix = mut.Set [Symbol ](defn.ScalaRuntimePackageClass )
335
340
336
341
/** Trivial definitions, avoid registering params */
337
342
private val trivialDefs = mut.Set .empty[Symbol ]
@@ -355,7 +360,7 @@ object CheckUnused:
355
360
* as the same element can be imported with different renaming.
356
361
*/
357
362
def registerUsed (sym : Symbol , name : Option [Name ], prefix : Type = NoType , includeForImport : Boolean = true )(using Context ): Unit =
358
- if sym.exists && ! isConstructorOfSynth(sym) && ! doNotRegister(sym) then
363
+ if sym.exists && ! isConstructorOfSynth(sym) && ! doNotRegister(sym) && ! doNotRegisterPrefix(prefix.typeSymbol) then
359
364
if sym.isConstructor then
360
365
// constructors are "implicitly" imported with the class
361
366
registerUsed(sym.owner, name = None , prefix, includeForImport = includeForImport)
0 commit comments