Skip to content

Missing cyclic reference check for method type parameter leads to stackoverflow #3882

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
smarter opened this issue Jan 21, 2018 · 0 comments
Closed

Comments

@smarter
Copy link
Member

smarter commented Jan 21, 2018

trait Ring[A <: Ring[A]]

object Test {
  def crash[T <: Ring[_ <: T]]: Ring[T] = ???
}

scalac:

error: illegal cyclic reference involving type T
  def crash[T <: Ring[_ <: T]]: Ring[T] = ???
                      ^

dotty:

Exception in thread "main" java.lang.StackOverflowError
        at dotty.tools.dotc.core.Types$TypeMap$$Lambda$238/1866161430.<init>(Unknown Source)
        at dotty.tools.dotc.core.Types$TypeMap$$Lambda$238/1866161430.get$Lambda(Unknown Source)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:3786)
        at dotty.tools.dotc.core.Substituters.subst1(Substituters.scala:35)
        at dotty.tools.dotc.core.Substituters.subst1$(Substituters.scala:24)
        at dotty.tools.dotc.core.Contexts$Context.subst1(Contexts.scala:67)
        at dotty.tools.dotc.core.Substituters$Subst1Map.apply(Substituters.scala:202)
        at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$6(Types.scala:3811)
        at dotty.tools.dotc.core.Types$VariantTraversal.atVariance(Types.scala:3741)
        at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:3811)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:3819)
...
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 22, 2018
…king

Two types can differ only in their LazyRefs, but still need to be treated
as the same for the purpose of subtype cycle checking.
odersky added a commit that referenced this issue Jan 22, 2018
Fix #3882: Take LazyRefs into account for monitored subtype checking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant