Skip to content

Commit d79603e

Browse files
Backport "Use result of lambda type of implicit in CheckUnused" to 3.7.2 (#23545)
Backports #23497 to the 3.7.2-RC2.
1 parent 871dfb7 commit d79603e

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
@@ -924,7 +924,7 @@ object CheckUnused:
924924
def isCanEqual: Boolean =
925925
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
926926
def isMarkerTrait: Boolean =
927-
sym.info.hiBound.allMembers.forall: d =>
927+
sym.info.hiBound.resultType.allMembers.forall: d =>
928928
val m = d.symbol
929929
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
930930
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)