Skip to content

Literal types don't work with quotes #7046

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

To reproduce this one, you'll need to compile with -Ycheck:all flag.

import scala.quoted._

inline def mcr: Any = ${mcrImpl}
def mcrImpl given (ctx: QuoteContext): Expr[Any] = {
  val tpl: Expr[1] = '{1}
  '{()}
}
Stack trace
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] Running (fork) dotty.tools.dotc.Main -classpath /Users/anatolii/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar:/Users/anatolii/Projects/dotty/dotty/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.18/dotty-library_0.18-0.18.0-bin-SNAPSHOT.jar -Ycheck:all ../pg/Lib.scala
checking ../pg/Lib.scala after phase frontend
checking ../pg/Lib.scala after phase inlinedPositions
checking ../pg/Lib.scala after phase staging
checking ../pg/Lib.scala after phase posttyper
checking ../pg/Lib.scala after phase pickler
checking ../pg/Lib.scala after phase reifyQuotes
exception while typing val tpl: quoted.Expr[1.type] =
  scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx) of class class dotty.tools.dotc.ast.Trees$ValDef # 1549
exception while typing {
  val tpl: quoted.Expr[1.type] =
    scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx)
  scala.quoted.Expr.unitExpr.apply(ctx)
} of class class dotty.tools.dotc.ast.Trees$Block # 1556
exception while typing def mcrImpl given (ctx: quoted.QuoteContext): quoted.Expr[Any] =
  {
    val tpl: quoted.Expr[1.type] =
      scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx)
    scala.quoted.Expr.unitExpr.apply(ctx)
  } of class class dotty.tools.dotc.ast.Trees$DefDef # 1557
exception while typing @scala.annotation.internal.SourceFile("../pg/Lib.scala") final module class
  Lib$package$
() extends Object(), _root_.scala.Serializable { this: Lib$package.type =>
  private def writeReplace(): AnyRef =
    new scala.runtime.ModuleSerializationProxy(classOf[Lib$package.type])
  inline def mcr: Any = null.asInstanceOf[Any]
  def mcrImpl given (ctx: quoted.QuoteContext): quoted.Expr[Any] =
    {
      val tpl: quoted.Expr[1.type] =
        scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx)
      scala.quoted.Expr.unitExpr.apply(ctx)
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 1559
exception while typing package <empty> {
  import scala.quoted._
  final lazy module val Lib$package: Lib$package$ = new Lib$package$()
  @scala.annotation.internal.SourceFile("../pg/Lib.scala") final module class
    Lib$package$
  () extends Object(), _root_.scala.Serializable { this: Lib$package.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Lib$package.type])
    inline def mcr: Any = null.asInstanceOf[Any]
    def mcrImpl given (ctx: quoted.QuoteContext): quoted.Expr[Any] =
      {
        val tpl: quoted.Expr[1.type] =
          scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx)
        scala.quoted.Expr.unitExpr.apply(ctx)
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 1560
*** error while checking ../pg/Lib.scala after phase reifyQuotes ***
exception occurred while compiling ../pg/Lib.scala
java.lang.AssertionError: assertion failed: Found:    quoted.Expr[Int]
Required: quoted.Expr[Int(1)]
tree = scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx) while compiling ../pg/Lib.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: Found:    quoted.Expr[Int]
Required: quoted.Expr[Int(1)]
tree = scala.quoted.Liftable.Liftable_Int_delegate.toExpr(1).apply(ctx)
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
	at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:488)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:265)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2187)
	at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:1478)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1990)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2060)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:280)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:265)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2130)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2174)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:456)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:705)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:708)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$2$$anonfun$1(TreeChecker.scala:438)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:169)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock$$anonfun$1(TreeChecker.scala:438)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withBlock(TreeChecker.scala:186)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedBlock(TreeChecker.scala:438)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2013)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2061)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:280)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:265)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2187)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1544)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$2$$anonfun$1(TreeChecker.scala:411)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:169)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef$$anonfun$1(TreeChecker.scala:414)
	at dotty.tools.dotc.transform.TreeChecker$Checker.withDefinedSyms(TreeChecker.scala:169)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedDefDef(TreeChecker.scala:415)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1993)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2060)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:280)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:265)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2130)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2174)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:456)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1673)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedClassDef(TreeChecker.scala:395)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1996)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2060)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:280)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:265)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2130)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2174)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedStats(TreeChecker.scala:456)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1797)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2036)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2061)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:124)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:280)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2099)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2111)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:265)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2187)
	at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:122)
	at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:94)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:316)
	at scala.collection.immutable.List.map(List.scala:286)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:318)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
	at dotty.tools.dotc.Run.compileSources(Run.scala:120)
	at dotty.tools.dotc.Run.compile(Run.scala:104)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:180)
	at dotty.tools.dotc.Driver.process(Driver.scala:149)
	at dotty.tools.dotc.Driver.process(Driver.scala:161)
	at dotty.tools.dotc.Driver.main(Driver.scala:188)
	at dotty.tools.dotc.Main.main(Main.scala)
[error] Nonzero exit code returned from runner: 1
[error] (dotty-compiler / Compile / runMain) Nonzero exit code returned from runner: 1
[error] Total time: 11 s, completed Aug 15, 2019 3:48:48 PM

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions