Skip to content

No warn implicit param of overriding method #22901

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 6 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
No warn implicit param of overriding method
  • Loading branch information
som-snytt committed Apr 2, 2025
commit 0ebb4db4d769688cb70b7f6b5c4166fceca93190
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 @@ -614,6 +614,7 @@ object CheckUnused:
|| sym.info.isInstanceOf[RefinedType] // can't be expressed as a context bound
if ctx.settings.WunusedHas.implicits
&& !infos.skip(m)
&& !m.nextOverriddenSymbol.exists
&& !allowed
then
if m.isPrimaryConstructor then
Expand Down
17 changes: 16 additions & 1 deletion tests/warn/i15503f.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object ExampleWithoutWith:
case '{ ${Expr(opt)} : Some[T] } => Some(opt)
case _ => None

//absolving names on matches of quote trees requires consulting non-abstract types in QuotesImpl
//nowarning names on matches of quote trees requires consulting non-abstract types in QuotesImpl
object Unmatched:
import scala.quoted.*
def transform[T](e: Expr[T])(using Quotes): Expr[T] =
Expand Down Expand Up @@ -84,3 +84,18 @@ package givens:
given namely: (x: X) => Y: // warn protected param to given class
def doY = "8"
end givens

object i22895:
trait Test[F[_], Ev] {
def apply[A, B](fa: F[A])(f: A => B)(using ev: Ev): F[B]
}
given testId: Test[[a] =>> a, Unit] =
new Test[[a] =>> a, Unit] {
def apply[A, B](fa: A)(f: A => B)(using ev: Unit): B = f(fa) // nowarn override
}
class C:
def f(using s: String) = s.toInt
class D(i: Int) extends C:
override def f(using String) = compute(i) // nowarn override
def g(using sss: String) = compute(i) // warn
def compute(i: Int) = i * 42 // returning a class param is deemed trivial, make it non-trivial