@@ -81,7 +81,7 @@ class CheckUnused extends MiniPhase:
8181 ctx
8282
8383 override def prepareForIdent (tree : tpd.Ident )(using Context ): Context =
84- if tree.symbol.exists then
84+ if tree.symbol.exists then
8585 _key.unusedDataApply(_.registerUsed(tree.symbol, Some (tree.name)))
8686 else if tree.hasType then
8787 _key.unusedDataApply(_.registerUsed(tree.tpe.classSymbol, Some (tree.name)))
@@ -103,7 +103,7 @@ class CheckUnused extends MiniPhase:
103103 override def prepareForValDef (tree : tpd.ValDef )(using Context ): Context =
104104 _key.unusedDataApply{ud =>
105105 // do not register the ValDef generated for `object`
106- if ! tree.symbol.is(Module ) then
106+ if ! tree.symbol.is(Module ) then
107107 ud.registerDef(tree)
108108 ud.addIgnoredUsage(tree.symbol)
109109 }
@@ -335,7 +335,7 @@ object CheckUnused:
335335 * The optional name will be used to target the right import
336336 * as the same element can be imported with different renaming
337337 */
338- def registerUsed (sym : Symbol , name : Option [Name ])(using Context ): Unit =
338+ def registerUsed (sym : Symbol , name : Option [Name ])(using Context ): Unit =
339339 if ! isConstructorOfSynth(sym) && ! doNotRegister(sym) then
340340 if sym.isConstructor && sym.exists then
341341 registerUsed(sym.owner, None ) // constructor are "implicitly" imported with the class
@@ -371,7 +371,7 @@ object CheckUnused:
371371 implicitParamInScope += memDef
372372 else
373373 explicitParamInScope += memDef
374- else if currScopeType.top == ScopeType .Local then
374+ else if currScopeType.top == ScopeType .Local then
375375 localDefInScope += memDef
376376 else if memDef.shouldReportPrivateDef then
377377 privateDefInScope += memDef
@@ -578,10 +578,10 @@ object CheckUnused:
578578 else
579579 false
580580
581- private def usedDefContains (using Context ): Boolean =
581+ private def usedDefContains (using Context ): Boolean =
582582 sym.everySymbol.exists(usedDef.apply)
583583
584- private def everySymbol (using Context ): List [Symbol ] =
584+ private def everySymbol (using Context ): List [Symbol ] =
585585 List (sym, sym.companionClass, sym.companionModule, sym.moduleClass).filter(_.exists)
586586
587587 end extension
@@ -614,10 +614,11 @@ object CheckUnused:
614614 private def isValidParam (using Context ): Boolean =
615615 val sym = memDef.symbol
616616 (sym.is(Param ) || sym.isAllOf(PrivateParamAccessor | Local , butNot = CaseAccessor )) &&
617- ! isSyntheticMainParam(sym) &&
618- ! sym.shouldNotReportParamOwner
617+ ! isSyntheticMainParam(sym) &&
618+ ! sym.shouldNotReportParamOwner &&
619+ (! sym.exists || ! sym.owner.isAllOf(Synthetic | PrivateLocal ))
619620
620- private def shouldReportPrivateDef (using Context ): Boolean =
621+ private def shouldReportPrivateDef (using Context ): Boolean =
621622 currScopeType.top == ScopeType .Template && ! memDef.symbol.isConstructor && memDef.symbol.is(Private , butNot = SelfName | Synthetic | CaseAccessor )
622623
623624 extension (imp : tpd.Import )
0 commit comments