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..6b7754d7e38f --- /dev/null +++ b/tests/pos/i10900.scala @@ -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) + } + } +}