Skip to content

Stack overflow when rendering structural types with self references in quotes reflect #23142

Closed as duplicate of#22649
@jchyb

Description

@jchyb

Compiler version

3.7.0 (and earlier and later)
Found when working on scaladoc

Minimized code

object Test:
  type R = { type T; val x: Int; type U <: this.T; }
  def main() = Macro.show[R]
import scala.quoted._
object Macro:
  inline def show[T] = ${ showImpl[T] }
  def showImpl[T: Type](using Quotes): Expr[Unit] =
    import quotes.reflect._
    println(TypeRepr.of[T].dealias.show(using Printer.TypeReprStructure))
    '{()}

Output

-- Error: /Users/jchyb/workspace/scala3/Test.scala:5:25 -------------------------
5 |  def main() = Macro.show[R]
  |               ^^^^^^^^^^^^^
  |               Exception occurred while executing macro expansion.
  |               java.lang.StackOverflowError
  |
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from Macro.scala:3
3 |  inline def show[T] = ${ showImpl[T] }
  |                       ^^^^^^^^^^^^^^^^
   -----------------------------------------------------------------------------

Expectation

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions