File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -544,11 +544,11 @@ object CheckUnused:
544544 warnAt(pos)(UnusedSymbol .privateMembers)
545545 else if ctx.settings.WunusedHas .explicits
546546 && ! sym.is(Synthetic ) // param to setter is unused bc there is no field yet
547- && ! (sym.owner.is(ExtensionMethod ) && {
548- m.paramSymss.dropWhile(_.exists(_.isTypeParam)) match
549- case (h :: Nil ) :: Nil => h == sym // param is the extended receiver
547+ && ! (sym.owner.is(ExtensionMethod ) &&
548+ m.paramSymss.dropWhile(_.exists(_.isTypeParam)). match
549+ case (h :: Nil ) :: _ => h == sym // param is the extended receiver
550550 case _ => false
551- } )
551+ )
552552 && ! sym.name.isInstanceOf [DerivedName ]
553553 && ! ctx.platform.isMainMethod(m)
554554 then
Original file line number Diff line number Diff line change 1+ //> using options -Wunused:explicits
2+
3+ // An external class that doesn't get its own `copy` method.
4+ class Foo (val a : String , val b : Int )
5+
6+ //
7+ // Example 1: add `copy` method via an extension method.
8+ //
9+ extension (self : Foo )
10+ def copy (a : String = self.a, b : Int = self.b): Foo = Foo (a, b) // nowarn
11+
12+ //
13+ // Example 2: implement `copyFoo` with parameter groups.
14+ //
15+ def copyFoo (foo : Foo )(a : String = foo.a, b : Int = foo.b): Foo = Foo (a, b) // warn
You can’t perform that action at this time.
0 commit comments