Skip to content

CyclicReference crash when expanding a macro that returns a refinement #7513

Closed
@biboudis

Description

@biboudis

The code below crashes during macro expansion of quote with a dotty.tools.dotc.core.CyclicReference.

minimized code

  trait Quoted {
    def foo: Int
  }
  inline def quote: Quoted = ${ quoteImpl }

  def quoteImpl(given qctx: QuoteContext): Expr[Quoted] = '{
    new Quoted {
      def foo = ???
    }
  }

same happens with val.

Exception occurred while executing macro expansion.
  |  dotty.tools.dotc.core.CyclicReference: 
  |     at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:154)
  |     at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:255)
  |     at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:182)
  |     at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:184)
  |     at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:397)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:802)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:737)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStat(TreeUnpickler.scala:932)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats$$anonfun$1(TreeUnpickler.scala:980)
  |     at dotty.tools.dotc.core.tasty.TastyReader.until(TastyReader.scala:127)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedStats(TreeUnpickler.scala:980)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readStats(TreeUnpickler.scala:984)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1096)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1203)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1108)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1203)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:999)
  |     at dotty.tools.dotc.core.tasty.TreeUnpickler.unpickle(TreeUnpickler.scala:104)
  |     at dotty.tools.dotc.core.tasty.DottyUnpickler.computeRootTrees(DottyUnpickler.scala:57)
  |     at dotty.tools.dotc.ast.tpd$TreeProvider.rootTrees(tpd.scala:1091)
  |     at dotty.tools.dotc.core.tasty.DottyUnpickler.rootTrees(DottyUnpickler.scala:39)
  |     at dotty.tools.dotc.ast.tpd$TreeProvider.tree(tpd.scala:1095)
  |     at dotty.tools.dotc.core.tasty.DottyUnpickler.tree(DottyUnpickler.scala:39)
  |     at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickle(PickledQuotes.scala:129)
  |     at dotty.tools.dotc.core.quoted.PickledQuotes$.unpickleExpr(PickledQuotes.scala:64)
  |     at dotty.tools.dotc.tastyreflect.ReflectionCompilerInterface.unpickleExpr(ReflectionCompilerInterface.scala:36)
  |     at scala.runtime.quoted.Unpickler$.unpickleExpr$direct(Unpickler.scala:16)
  |     at Test$.quoteImpl(Test_1.scala:55)

expectation

Should work

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions