Skip to content

Commit 8c6915c

Browse files
authored
Merge pull request #515 from scala/backport-lts-3.3-23497
Backport "Use result of lambda type of implicit in CheckUnused" to 3.3 LTS
2 parents eb44709 + 40111e8 commit 8c6915c

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
@@ -964,7 +964,7 @@ object CheckUnused:
964964
def isCanEqual: Boolean =
965965
sym.isOneOf(GivenOrImplicit) && sym.info.finalResultType.baseClasses.exists(_.derivesFrom(defn.CanEqualClass))
966966
def isMarkerTrait: Boolean =
967-
sym.info.hiBound.allMembers.forall: d =>
967+
sym.info.hiBound.resultType.allMembers.forall: d =>
968968
val m = d.symbol
969969
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
970970
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
@@ -58,6 +58,8 @@ package givens:
5858
trait Y:
5959
def doY: String
6060

61+
trait Z
62+
6163
given X with
6264
def doX = 7
6365

@@ -75,6 +77,9 @@ package givens:
7577

7678
given namely (using x: X): Y with // warn protected param to given class
7779
def doY = "8"
80+
81+
def f(using => X) = println() // warn
82+
def g(using => Z) = println() // nowarn marker trait
7883
end givens
7984

8085
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)