Skip to content

Commit 1c127e8

Browse files
authored
Merge pull request #12747 from dotty-staging/fix-10900
Fix #10900: Avoid loop for F-bounds in checkCanEqual
2 parents 9696219 + 87d0ddc commit 1c127e8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ trait Implicits:
926926
apply(t.widen)
927927
case t: RefinedType =>
928928
apply(t.parent)
929+
case t: LazyRef =>
930+
t
929931
case _ =>
930932
if (variance > 0) mapOver(t) else t
931933
}

tests/pos/i10900.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import scala.collection.IterableOps
2+
def foo[CC[A] <: IterableOps[A, CC, CC[A]], A](collection: CC[A]) =
3+
collection == collection
4+
5+
object Test1 {
6+
import scala.collection.IterableOps
7+
implicit class RichCollection[CC[A] <: IterableOps[A, CC, CC[A]], A](val collection: CC[A]) {
8+
def awm(update: CC[A] => CC[A]): CC[A] = {
9+
val newCollection = update(collection)
10+
if (newCollection == collection) collection else newCollection.awm(update)
11+
}
12+
}
13+
}
14+
15+
object Test2 {
16+
import scala.collection.IterableOps
17+
implicit class RichCollection[CC[A] <: IterableOps[A, CC, CC[A]], A](val collection: CC[A]) {
18+
def awm(update: CC[A] => CC[A]): CC[A] = update(collection) match {
19+
case `collection` => collection
20+
case updated => updated.awm(update)
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)