Skip to content

Recursion limit error typechecking value of abstract type with type member and subtyping #4560

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

Open
pweisenburger opened this issue May 22, 2018 · 6 comments · May be fixed by #20236
Open

Comments

@pweisenburger
Copy link
Contributor

The following code compiles using Scala but crashes Dotty with a StackOverflowError:

trait Trait {
  type A <: { type T = B }
  type B <: A
}

trait SubTrait extends Trait {
  val v: A
}
@newca12
Copy link
Contributor

newca12 commented May 22, 2018

PR #4385 fix the stack overflow
Is there an illegal cyclic reference not detected by scalac ?

@pweisenburger
Copy link
Contributor Author

PR #4385 fix the stack overflow

That's good to know

Is there an illegal cyclic reference not detected by scalac ?

Not sure. I don't think this code should be illegal.

@smarter
Copy link
Member

smarter commented May 23, 2018

Here's another way to reproduce the same issue:

trait Trait {
  type A <: { type T = B }
  type B <: { type S = A }
}
trait SubTrait extends Trait {
  val v: A
}

I agree that this should compile since it's fairly easy to come up with concrete types for A and B:

class XA {
  type T = XB
}
class XB {
  type S = XA
}

class Foo extends Trait {
  type A = XA
  type B = XB
}

@xuwei-k
Copy link
Contributor

xuwei-k commented May 25, 2021

Is this same issue? 👀

https://github.com/playframework/play-ws/blob/735b38213011d4905426709205335a515a0333d7/play-ws-standalone/src/main/scala/play/api/libs/ws/StandaloneWSRequest.scala#L23-L24

libraryDependencies += "com.typesafe.play" %% "play-ws-standalone" % "2.1.2" cross CrossVersion.for3Use2_13

scalaVersion := "3.0.0"
package example

import play.api.libs.ws.StandaloneWSClient
import scala.concurrent.duration.Duration

trait Test {

  def ws: StandaloneWSClient

  def url: String

  def requestTimeout: Duration

  def header: Seq[(String, String)]

  def foo = {
    ws
      .url(url)
      .withHttpHeaders(header: _*)
      .withRequestTimeout(requestTimeout)
      .withBody("body")
      .withMethod("POST")
      .execute()
  }

}
[error] 20 |      .withRequestTimeout(requestTimeout)
[error]    |                         ^
[error]    |Recursion limit exceeded.
[error]    |Maybe there is an illegal cyclic reference?
[error]    |If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
[error]    |A recurring operation is (inner to outer):
[error]    |
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))]
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))]
[error]    |  subtype [cannot display due to assertion failed, raw string = AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self))] <:< [cannot display due to assertion failed, raw string = AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self))]
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))]
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))]
[error]    |  subtype [cannot display due to assertion failed, raw string = AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self))] <:< [cannot display due to assertion failed, raw string = AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self))]
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))]
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))]
[error]    |  subtype [cannot display due to assertion failed, raw string = AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self))] <:< [cannot display due to assertion failed, raw string = AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self))]
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))]
[error]    |  ...
[error]    |
[error]    |  subtype [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self)))] <:< [cannot display due to assertion failed, raw string = TypeBounds(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing)),AndType(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null))),TypeRef(TypeRef(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),type Self),type Self)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype LazyRef(play.api.libs.ws.StandaloneWSRequest#Self#Self) <:< [cannot display due to assertion failed, raw string = RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class ws)),trait StandaloneWSRequest),Self,TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),LazyRef(null)))]
[error]    |  subtype play.api.libs.ws.StandaloneWSRequest#Self#Self <:< ?{ withBody: ? }
[error] one error found

@smarter
Copy link
Member

smarter commented May 25, 2021

The error message refers to different operations so probably not.

@xuwei-k
Copy link
Contributor

xuwei-k commented Jun 7, 2021

Is this same issue? 👀

The error message refers to different operations so probably not.

#12731

@ckipp01 ckipp01 changed the title Stack overflow typechecking value of abstract type with type member and subtyping Recursion limit error typechecking value of abstract type with type member and subtyping May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants