Skip to content

Use result of lambda type of implicit in CheckUnused #23497

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ object CheckUnused:
def isCanEqual: Boolean =
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
def isMarkerTrait: Boolean =
sym.info.hiBound.allMembers.forall: d =>
sym.info.hiBound.resultType.allMembers.forall: d =>
val m = d.symbol
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
def isEffectivelyPrivate: Boolean =
Expand Down
7 changes: 6 additions & 1 deletion tests/warn/i15503f.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Wunused:implicits
//> using options -Wunused:implicits

/* This goes around the "trivial method" detection */
val default_int = 1
Expand Down Expand Up @@ -67,6 +67,8 @@ package givens:
trait Y:
def doY: String

trait Z

given X:
def doX = 7

Expand All @@ -84,6 +86,9 @@ package givens:

given namely: (x: X) => Y: // warn protected param to given class
def doY = "8"

def f(using => X) = println() // warn
def g(using => Z) = println() // nowarn marker trait
end givens

object i22895:
Expand Down
15 changes: 15 additions & 0 deletions tests/warn/i23494.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//> using options -Wunused:implicits

import scala.deriving.Mirror

abstract class EnumerationValues[A]:
type Out

object EnumerationValues:
type Aux[A, B] = EnumerationValues[A] { type Out = B }

def apply[A, B](): EnumerationValues.Aux[A, B] = new EnumerationValues[A]:
override type Out = B

given sum[A, B <: Tuple](using mirror: Mirror.SumOf[A] { type MirroredElemTypes = B }): EnumerationValues.Aux[A, A] =
EnumerationValues[A, A]()
Loading