Skip to content

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

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
anatoliykmetyuk opened this issue Nov 15, 2019 · 0 comments · Fixed by #9984
Closed
Milestone

Comments

@anatoliykmetyuk
Copy link
Contributor

anatoliykmetyuk commented Nov 15, 2019

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
@anatoliykmetyuk anatoliykmetyuk changed the title Widening a generic type from Tasty Reflect leads to a CyclicReference exception Showing a widened generic type from Tasty Reflect leads to a CyclicReference exception Nov 15, 2019
@nicolasstucki nicolasstucki linked a pull request Jan 14, 2021 that will close this issue
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants