Skip to content

No warning for parameter of overriding method #22757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ object CheckUnused:
end checkExplicit
// begin
if !infos.skip(m)
&& !m.nextOverriddenSymbol.exists
&& !allowed
then
checkExplicit()
Expand Down
4 changes: 2 additions & 2 deletions tests/warn/i15503e.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ package foo.test.i16865:
trait Bar extends Foo

object Ex extends Bar:
def fn(a: Int, b: Int): Int = b + 3 // warn
def fn(a: Int, b: Int): Int = b + 3 // no warn (override)

object Ex2 extends Bar:
override def fn(a: Int, b: Int): Int = b + 3 // warn
override def fn(a: Int, b: Int): Int = b + 3 // no warn (override)

final class alpha(externalName: String) extends StaticAnnotation // no warn annotation arg

Expand Down
10 changes: 10 additions & 0 deletions tests/warn/i22742.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//> using options -Wunused:all -Werror

trait Foldable[F[_]]:
def foldLeft[A, B](fa: F[A], b: B)(f: (B, A) => B): B

type Id[A] = A

given foldableId: Foldable[Id] =
new Foldable[Id]:
def foldLeft[A, B](fa: Id[A], b: B)(f: (B, A) => B): B = b
2 changes: 1 addition & 1 deletion tests/warn/scala2-t11681.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait BadAPI extends InterFace {
a
}
override def call(a: Int,
b: String, // warn now
b: String, // no warn (override)
c: Double): Int = {
println(c)
a
Expand Down
4 changes: 2 additions & 2 deletions tests/warn/unused-params.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait BadAPI extends InterFace {
a
}
override def call(a: Int,
b: String, // warn
b: String, // no warn (override)
c: Double): Int = {
println(c)
a
Expand Down Expand Up @@ -136,7 +136,7 @@ trait BadMix { self: InterFace =>
}

class Unequal {
override def equals(other: Any) = toString.nonEmpty // warn
override def equals(other: Any) = toString.nonEmpty // no warn (override)
}

class Seriously {
Expand Down
Loading