Skip to content

Fix #10900: Avoid loop for F-bounds in checkCanEqual #12747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -929,6 +929,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)
}
}
}