From 960164225ddcc531cc57ff6feab3191478a2e75e Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 8 Jun 2021 15:49:17 +0200 Subject: [PATCH 1/2] Fix #10900: Avoid loop for F-bounds in checkCanEqual --- compiler/src/dotty/tools/dotc/typer/Implicits.scala | 2 ++ tests/pos/i10900.scala | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 tests/pos/i10900.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index ae3b04d37657..823e47eceba5 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -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 } diff --git a/tests/pos/i10900.scala b/tests/pos/i10900.scala new file mode 100644 index 000000000000..8f22a1f9991c --- /dev/null +++ b/tests/pos/i10900.scala @@ -0,0 +1,3 @@ +import scala.collection.IterableOps +def foo[CC[A] <: IterableOps[A, CC, CC[A]], A](collection: CC[A]) = + collection == collection From 87d0ddcbcae4f5fabeed676c0fbeadb08ce5c4af Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 8 Jun 2021 15:52:51 +0200 Subject: [PATCH 2/2] Add original tests --- tests/pos/i10900.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/pos/i10900.scala b/tests/pos/i10900.scala index 8f22a1f9991c..6b7754d7e38f 100644 --- a/tests/pos/i10900.scala +++ b/tests/pos/i10900.scala @@ -1,3 +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) + } + } +}