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 @@ -548,11 +548,11 @@ object CheckUnused:
548548 warnAt(pos)(UnusedSymbol .privateMembers)
549549 else if ctx.settings.WunusedHas .explicits
550550 && ! sym.is(Synthetic ) // param to setter is unused bc there is no field yet
551- && ! (sym.owner.is(ExtensionMethod ) && {
552- m.paramSymss.dropWhile(_.exists(_.isTypeParam)) match
553- case (h :: Nil ) :: Nil => h == sym // param is the extended receiver
551+ && ! (sym.owner.is(ExtensionMethod ) &&
552+ m.paramSymss.dropWhile(_.exists(_.isTypeParam)). match
553+ case (h :: Nil ) :: _ => h == sym // param is the extended receiver
554554 case _ => false
555- } )
555+ )
556556 && ! sym.name.isInstanceOf [DerivedName ]
557557 && ! ctx.platform.isMainMethod(m)
558558 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