Skip to content

Commit 37649ed

Browse files
committed
Use result of lambda type of implicit in CheckUnused
1 parent 8a14de3 commit 37649ed

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ object CheckUnused:
926926
def isCanEqual: Boolean =
927927
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
928928
def isMarkerTrait: Boolean =
929-
sym.info.hiBound.allMembers.forall: d =>
929+
sym.info.hiBound.resultType.allMembers.forall: d =>
930930
val m = d.symbol
931931
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
932932
def isEffectivelyPrivate: Boolean =

tests/warn/i15503f.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Wunused:implicits
1+
//> using options -Wunused:implicits
22

33
/* This goes around the "trivial method" detection */
44
val default_int = 1
@@ -67,6 +67,8 @@ package givens:
6767
trait Y:
6868
def doY: String
6969

70+
trait Z
71+
7072
given X:
7173
def doX = 7
7274

@@ -84,6 +86,9 @@ package givens:
8486

8587
given namely: (x: X) => Y: // warn protected param to given class
8688
def doY = "8"
89+
90+
def f(using => X) = println() // warn
91+
def g(using => Z) = println() // nowarn marker trait
8792
end givens
8893

8994
object i22895:

tests/warn/i23494.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//> using options -Wunused:implicits
2+
3+
import scala.deriving.Mirror
4+
5+
abstract class EnumerationValues[A]:
6+
type Out
7+
8+
object EnumerationValues:
9+
type Aux[A, B] = EnumerationValues[A] { type Out = B }
10+
11+
def apply[A, B](): EnumerationValues.Aux[A, B] = new EnumerationValues[A]:
12+
override type Out = B
13+
14+
given sum[A, B <: Tuple](using mirror: Mirror.SumOf[A] { type MirroredElemTypes = B }): EnumerationValues.Aux[A, A] =
15+
EnumerationValues[A, A]()

0 commit comments

Comments
 (0)