Skip to content

Infinite loop in subtyping when a default parameter has an F-bounded type #1103

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

Closed
Sciss opened this issue Feb 18, 2016 · 3 comments · Fixed by #1107
Closed

Infinite loop in subtyping when a default parameter has an F-bounded type #1103

Sciss opened this issue Feb 18, 2016 · 3 comments · Fixed by #1107

Comments

@Sciss
Copy link
Contributor

Sciss commented Feb 18, 2016

Steps to reproduce:

$ git clone -b dotty [email protected]:Sciss/Lucre.git
$ cd Lucre
$ sbt compile

This crashes with the following trace: https://gist.github.com/smarter/975785e299847135de41

@smarter
Copy link
Member

smarter commented Feb 18, 2016

Compiling with -Yno-deep-subtypes -Ylog:all gives some more information:

[log frontend] !!! deep subtype recursion involving S <:< de.sciss.lucre.stm.Sys, constraint = ...
exception occurred while typechecking core/src/main/scala/de/sciss/lucre/event/Map.scala

@smarter smarter changed the title Infinite loop (stack-overflow) in type checker Infinite loop (stack-overflow) in subtyping when compiling Lucre Feb 18, 2016
@smarter
Copy link
Member

smarter commented Feb 18, 2016

OK, minimized:

class Sys[S]
case class Foo[T <: Sys[T]](t: T)

@smarter smarter changed the title Infinite loop (stack-overflow) in subtyping when compiling Lucre Infinite loop in subtyping with F-bounded case class Feb 18, 2016
@smarter
Copy link
Member

smarter commented Feb 18, 2016

Minimized further to not require a case class:

class Sys[S]
class Foo[T <: Sys[T]] {
  val t: T = ???
  def foo[A <: Sys[A]](x: A = t) = x
}

@smarter smarter changed the title Infinite loop in subtyping with F-bounded case class Infinite loop in subtyping when a default parameter has an F-bounded type Feb 18, 2016
smarter added a commit to dotty-staging/dotty that referenced this issue Feb 18, 2016
Before this commit, the output of `wildApprox(A)` where `A <: Sys[LazyRef(A)]` was
`? <: Sys[LazyRef(() => wildApprox(A))]`. This lead to infinite
subtyping checks.

This is fixed by always approximating a LazyRef by an unbounded
wildcard. Since we only create LazyRefs when we encounter a cycle, this
should be safe.

Fix scala#1103.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants