Skip to content

Handle case where typevar instance is fully determined #2435

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
May 16, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
override def toString: String = {
def entryText(tp: Type): String = tp match {
case tp: TypeBounds => tp.toString
case _ =>" := " + tp
case _ => " := " + tp
}
val constrainedText =
" constrained types = " + domainLambdas.mkString("\n")
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ object Inferencing {
// val y: List[List[String]] = List(List(1))
if (!hasUnreportedErrors)
vs foreachBinding { (tvar, v) =>
if (v != 0) {
if (v != 0 && ctx.typerState.constraint.contains(tvar)) {
// previous interpolations could have already instantiated `tvar`
// through unification, that's why we have to check again whether `tvar`
// is contained in the current constraint.
typr.println(s"interpolate ${if (v == 1) "co" else "contra"}variant ${tvar.show} in ${tp.show}")
tvar.instantiate(fromBelow = v == 1)
}
Expand Down
22 changes: 22 additions & 0 deletions tests/pos/strawman-i79.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
object Empty
extends App {

trait Iterable[+A]
extends IterableOnce[A]

trait IterableOps[+A, +CC[X], +C] {
def ++[B >: A](xs: IterableOnce[B]): CC[B] = ???
}

trait IterableOnce[+A]

class LazyList[+A]()
extends IterableOps[A, LazyList, LazyList[A]]
with Iterable[A]

object LazyList {
def empty[A <: Any]: LazyList[A] = new LazyList[A]()
}

LazyList.empty ++ LazyList.empty
}