Skip to content

Commit 5d6a151

Browse files
som-snytttgodzik
authored andcommitted
No warn param of overriding method
[Cherry-picked 825baf9]
1 parent b713012 commit 5d6a151

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ object CheckUnused:
573573
end checkExplicit
574574
// begin
575575
if !infos.skip(m)
576+
&& !m.nextOverriddenSymbol.exists
576577
&& !allowed
577578
then
578579
checkExplicit()

tests/warn/i15503e.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ package foo.test.i16865:
7070
trait Bar extends Foo
7171

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

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

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

tests/warn/i22742.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//> using options -Wunused:all -Werror
2+
3+
trait Foldable[F[_]]:
4+
def foldLeft[A, B](fa: F[A], b: B)(f: (B, A) => B): B
5+
6+
type Id[A] = A
7+
8+
given foldableId: Foldable[Id] =
9+
new Foldable[Id]:
10+
def foldLeft[A, B](fa: Id[A], b: B)(f: (B, A) => B): B = b

tests/warn/scala2-t11681.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait BadAPI extends InterFace {
2323
a
2424
}
2525
override def call(a: Int,
26-
b: String, // warn now
26+
b: String, // no warn (override)
2727
c: Double): Int = {
2828
println(c)
2929
a

tests/warn/unused-params.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait BadAPI extends InterFace {
2323
a
2424
}
2525
override def call(a: Int,
26-
b: String, // warn
26+
b: String, // no warn (override)
2727
c: Double): Int = {
2828
println(c)
2929
a
@@ -136,7 +136,7 @@ trait BadMix { self: InterFace =>
136136
}
137137

138138
class Unequal {
139-
override def equals(other: Any) = toString.nonEmpty // warn
139+
override def equals(other: Any) = toString.nonEmpty // no warn (override)
140140
}
141141

142142
class Seriously {

0 commit comments

Comments
 (0)