Skip to content

Commit 0ebb4db

Browse files
committed
No warn implicit param of overriding method
1 parent a8cf11d commit 0ebb4db

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ object CheckUnused:
614614
|| sym.info.isInstanceOf[RefinedType] // can't be expressed as a context bound
615615
if ctx.settings.WunusedHas.implicits
616616
&& !infos.skip(m)
617+
&& !m.nextOverriddenSymbol.exists
617618
&& !allowed
618619
then
619620
if m.isPrimaryConstructor then

tests/warn/i15503f.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object ExampleWithoutWith:
4242
case '{ ${Expr(opt)} : Some[T] } => Some(opt)
4343
case _ => None
4444

45-
//absolving names on matches of quote trees requires consulting non-abstract types in QuotesImpl
45+
//nowarning names on matches of quote trees requires consulting non-abstract types in QuotesImpl
4646
object Unmatched:
4747
import scala.quoted.*
4848
def transform[T](e: Expr[T])(using Quotes): Expr[T] =
@@ -84,3 +84,18 @@ package givens:
8484
given namely: (x: X) => Y: // warn protected param to given class
8585
def doY = "8"
8686
end givens
87+
88+
object i22895:
89+
trait Test[F[_], Ev] {
90+
def apply[A, B](fa: F[A])(f: A => B)(using ev: Ev): F[B]
91+
}
92+
given testId: Test[[a] =>> a, Unit] =
93+
new Test[[a] =>> a, Unit] {
94+
def apply[A, B](fa: A)(f: A => B)(using ev: Unit): B = f(fa) // nowarn override
95+
}
96+
class C:
97+
def f(using s: String) = s.toInt
98+
class D(i: Int) extends C:
99+
override def f(using String) = compute(i) // nowarn override
100+
def g(using sss: String) = compute(i) // warn
101+
def compute(i: Int) = i * 42 // returning a class param is deemed trivial, make it non-trivial

0 commit comments

Comments
 (0)