Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Don't warn retainedBody
  • Loading branch information
som-snytt committed Feb 4, 2025
commit 8d3954f8095a6705c0aaaf103245f071943c48a3
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Flags.*
import dotty.tools.dotc.core.Names.{Name, SimpleName, DerivedName, TermName, termName}
import dotty.tools.dotc.core.NameOps.{isAnonymousFunctionName, isReplWrapperName}
import dotty.tools.dotc.core.NameKinds.{ContextBoundParamName, ContextFunctionParamName, WildcardParamName}
import dotty.tools.dotc.core.NameKinds.{BodyRetainerName, ContextBoundParamName, ContextFunctionParamName, WildcardParamName}
import dotty.tools.dotc.core.StdNames.nme
import dotty.tools.dotc.core.Symbols.{ClassSymbol, NoSymbol, Symbol, defn, isDeprecated, requiredClass, requiredModule}
import dotty.tools.dotc.core.Types.*
Expand Down Expand Up @@ -511,6 +511,7 @@ object CheckUnused:
if ctx.settings.WunusedHas.privates
&& !sym.isPrimaryConstructor
&& sym.is(Private, butNot = SelfName | Synthetic | CaseAccessor)
&& !sym.name.is(BodyRetainerName)
&& !sym.isSerializationSupport
&& !(sym.is(Mutable) && sym.isSetter && sym.owner.is(Trait)) // tracks sym.underlyingSymbol sibling getter
then
Expand Down
14 changes: 14 additions & 0 deletions tests/warn/t22507.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

//> using options -Werror -Wunused:privates

case class BinaryFen(value: Array[Byte]) extends AnyVal:

def read: Unit =
val reader = new Iterator[Byte]:
val inner = value.iterator
override inline def hasNext: Boolean = inner.hasNext // nowarn
override inline def next: Byte = if hasNext then inner.next else 0.toByte // nowarn

if reader.hasNext then
val b: Byte = reader.next
println(b)
Loading