Skip to content

CyclicReference when showing a generic type from a macro #8858

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 May 1, 2020 · 0 comments · Fixed by #9984
Closed

CyclicReference when showing a generic type from a macro #8858

anatoliykmetyuk opened this issue May 1, 2020 · 0 comments · Fixed by #9984

Comments

@anatoliykmetyuk
Copy link
Contributor

anatoliykmetyuk commented May 1, 2020

Minimized code

macro.scala

import scala.quoted._

inline def mcr(inline x: Any): Any = ${ mcrImpl('x) }
def mcrImpl(expr: Expr[Any])(using ctx: QuoteContext): Expr[Any] =
  import ctx.tasty._
  expr.unseal match
    case Inlined(_, _, id1) =>
      println(id1.tpe.widen.show)
  '{()}

test.scala

trait Foo[A]
def check[T](x: Foo[T]) = mcr(x)

launch.iss (to reproduce with Dotty Issue Workspace)

$ rm -rv $here/*.tasty $here/*.class || true

dotty-bootstrapped/dotc -d $here
  $here/macro.scala

dotty-bootstrapped/dotc -d $here
  -classpath $here
  $here/test.scala

Output (click arrow to expand)

-- Error: /Users/kmetiuk/Projects/scala3/playground/utest-issue-1/test.scala:2:29
2 |def check[T](x: Foo[T]) = mcr(x)
  |                          ^^^^^^
  |Exception occurred while executing macro expansion.
  |dotty.tools.dotc.core.CyclicReference:
  |	at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:156)
  |	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:257)
  |	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:186)
  |	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:188)
  |	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:446)
  |	at dotty.tools.dotc.core.SymDenotations$SymDenotation.flags(SymDenotations.scala:158)
  |	at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.Symbol_flags(ReflectionCompilerInterface.scala:1669)
  |	at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.Symbol_flags(ReflectionCompilerInterface.scala:1669)
  |	at scala.tasty.Reflection$SymbolOps$.flags(Reflection.scala:2129)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printType(SourceCodePrinter.scala:1087)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTypeOrBound(SourceCodePrinter.scala:1067)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printSeparated$9(SourceCodePrinter.scala:722)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTypesOrBounds(SourceCodePrinter.scala:728)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printType$$anonfun$1(SourceCodePrinter.scala:1131)
  |	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.inSquare(SourceCodePrinter.scala:81)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printType(SourceCodePrinter.scala:1131)
  |	at scala.tasty.reflect.SourceCodePrinter$Buffer.printTypeOrBound(SourceCodePrinter.scala:1067)
  |	at scala.tasty.reflect.SourceCodePrinter.showTypeOrBounds(SourceCodePrinter.scala:16)
  |	at scala.tasty.Reflection$TypeOrBoundsOps$.showWith(Reflection.scala:1597)
  |	at scala.tasty.Reflection$TypeOrBoundsOps$.show(Reflection.scala:1593)
  |	at macro$package$.mcrImpl(macro.scala:8)
  |
  | This location contains code that was inlined from test.scala:2
1 error found
anatoliykmetyuk added a commit to dotty-staging/utest that referenced this issue May 1, 2020
@nicolasstucki nicolasstucki removed their assignment May 4, 2020
@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.

3 participants