@@ -114,6 +114,10 @@ class CheckUnused extends MiniPhase:
114114
115115 override def prepareForDefDef (tree : tpd.DefDef )(using Context ): Context =
116116 unusedDataApply{ ud =>
117+ if ! tree.rawMods.is(Private ) then
118+ tree.termParamss.flatten.foreach { p =>
119+ ud.addIgnoredParam(p.symbol)
120+ }
117121 import ud .registerTrivial
118122 tree.registerTrivial
119123 traverseAnnotations(tree.symbol)
@@ -331,6 +335,8 @@ object CheckUnused:
331335 /** Trivial definitions, avoid registering params */
332336 private val trivialDefs = MutSet [Symbol ]()
333337
338+ private val paramsToSkip = MutSet [Symbol ]()
339+
334340 /**
335341 * Push a new Scope of the given type, executes the given Unit and
336342 * pop it back to the original type.
@@ -365,6 +371,10 @@ object CheckUnused:
365371 def removeIgnoredUsage (sym : Symbol )(using Context ): Unit =
366372 doNotRegister --= sym.everySymbol
367373
374+ def addIgnoredParam (sym : Symbol )(using Context ): Unit =
375+ paramsToSkip += sym
376+
377+
368378
369379 /** Register an import */
370380 def registerImport (imp : tpd.Import )(using Context ): Unit =
@@ -380,7 +390,7 @@ object CheckUnused:
380390 if memDef.isValidParam then
381391 if memDef.symbol.isOneOf(GivenOrImplicit ) then
382392 implicitParamInScope += memDef
383- else
393+ else if ! paramsToSkip.contains(memDef.symbol) then
384394 explicitParamInScope += memDef
385395 else if currScopeType.top == ScopeType .Local then
386396 localDefInScope += memDef
0 commit comments