Skip to content

Showing a widened generic type from Tasty Reflect leads to a CyclicReference exception #7558

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

Macro.scala

import scala.quoted._

inline def mcr(expr: => Any): Any = ${mcrImpl('expr)}

def mcrImpl(expr: Expr[Any])(using Quotes): Expr[Any] =
  import quotes.reflect._
  expr.asTerm.tpe.widen.show
  expr

Test.scala

def eq[T](p: T) = mcr(p)
Crash
-- Error: /Users/anatolii/Projects/dotty/pg/sandbox/Test.scala:1:21 ------------
1 |def eq[T](p: T) = mcr(p)
  |                  ^^^^^^
  |              Exception occurred while executing macro expansion.
  |              dotty.tools.dotc.core.CyclicReference: 
  |                     at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:155)
  |                     at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:165)
  |                     at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
  |                     at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
  |                     at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
  |                     at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:65)
  |                     at scala.quoted.runtime.impl.QuotesImpl$reflect$SymbolMethods$.flags(QuotesImpl.scala:2358)
  |                     at scala.quoted.runtime.impl.QuotesImpl$reflect$SymbolMethods$.flags(QuotesImpl.scala:2358)
  |                     at scala.quoted.runtime.impl.printers.SourceCode$SourceCodePrinter.printType(SourceCode.scala:1088)
  |                     at scala.quoted.runtime.impl.printers.SourceCode$.showType(SourceCode.scala:13)
  |                     at scala.quoted.runtime.impl.QuotesImpl$$anon$14.show(QuotesImpl.scala:2788)
  |                     at scala.quoted.runtime.impl.QuotesImpl$$anon$14.show(QuotesImpl.scala:2787)
  |                     at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.show(QuotesImpl.scala:1604)
  |                     at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.show(QuotesImpl.scala:1604)
  |                     at Macro_1$package$.mcrImpl(Macro_1.scala:7)
  |
  | This location contains code that was inlined from Test_2.scala:1
one error found

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions