Skip to content

Commit

Permalink
Merge pull request #12747 from dotty-staging/fix-10900
Browse files Browse the repository at this point in the history
Fix #10900: Avoid loop for F-bounds in checkCanEqual
  • Loading branch information
odersky authored Aug 30, 2021
2 parents 9696219 + 87d0ddc commit 1c127e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ trait Implicits:
apply(t.widen)
case t: RefinedType =>
apply(t.parent)
case t: LazyRef =>
t
case _ =>
if (variance > 0) mapOver(t) else t
}
Expand Down
23 changes: 23 additions & 0 deletions tests/pos/i10900.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import scala.collection.IterableOps
def foo[CC[A] <: IterableOps[A, CC, CC[A]], A](collection: CC[A]) =
collection == collection

object Test1 {
import scala.collection.IterableOps
implicit class RichCollection[CC[A] <: IterableOps[A, CC, CC[A]], A](val collection: CC[A]) {
def awm(update: CC[A] => CC[A]): CC[A] = {
val newCollection = update(collection)
if (newCollection == collection) collection else newCollection.awm(update)
}
}
}

object Test2 {
import scala.collection.IterableOps
implicit class RichCollection[CC[A] <: IterableOps[A, CC, CC[A]], A](val collection: CC[A]) {
def awm(update: CC[A] => CC[A]): CC[A] = update(collection) match {
case `collection` => collection
case updated => updated.awm(update)
}
}
}

0 comments on commit 1c127e8

Please sign in to comment.