Skip to content

AssertionError when calling constructor proxies from macro #13479

@Jasper-M

Description

@Jasper-M

Compiler version

3.0.2

Minimized code

import scala.quoted.*

inline def make[A <: AnyRef]: A = ${ makeMacro[A] }

def makeMacro[A <: AnyRef : Type](using Quotes): Expr[A] =
  import quotes.reflect.*

  TypeRepr.of[A].classSymbol.map{ sym =>
    Select.overloaded(Ref(sym.companionModule), "apply",  Nil, Nil).asExprOf[A]
  }
  .getOrElse(report.throwError("not a class"))

Output (click arrow to expand)

scala> make[String]
[error] (run-main-9) java.lang.AssertionError: assertion failed: Select(New(TypedSplice(Ident(String))),<init>)
[error] java.lang.AssertionError: assertion failed: Select(New(TypedSplice(Ident(String))),<init>)
[error] 	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedSelect(Inliner.scala:1491)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2663)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2755)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1622)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
[error] 	at dotty.tools.dotc.typer.Typer.newExpr$1(Typer.scala:3772)
[error] 	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3804)
[error] 	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3162)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
[error] 	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:882)
[error] 	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1032)
[error] 	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:317)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedApply(Inliner.scala:1535)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2693)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1622)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2818)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
[error] 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedApply(Inliner.scala:1540)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2693)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1622)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:62)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2698)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:118)
[error] 	at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1622)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2818)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
[error] 	at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:1016)
[error] 	at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:153)
[error] 	at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:86)
[error] 	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1454)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
[error] 	at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:111)
[error] 	at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
[error] 	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1463)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
[error] 	at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
[error] 	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1474)
[error] 	at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
[error] 	at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:94)
[error] 	at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:72)
[error] 	at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
[error] 	at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:44)
[error] 	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303)
[error] 	at scala.collection.immutable.List.map(List.scala:246)
[error] 	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
[error] 	at dotty.tools.dotc.transform.Inlining.runOn(Inlining.scala:48)
[error] 	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] 	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] 	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] 	at dotty.tools.dotc.Run.runPhases$5(Run.scala:216)
[error] 	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] 	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] 	at dotty.tools.dotc.Run.compileUnits(Run.scala:231)
[error] 	at dotty.tools.dotc.Run.compileUnits(Run.scala:172)
[error] 	at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:152)
[error] 	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:162)
[error] 	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:250)
[error] 	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:213)
[error] 	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:147)
[error] 	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:150)
[error] 	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:169)
[error] 	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:150)
[error] 	at xsbt.ConsoleInterface.run(ConsoleInterface.java:52)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[error] 	at sbt.internal.inc.AnalyzingCompiler.invoke(AnalyzingCompiler.scala:329)
[error] 	at sbt.internal.inc.AnalyzingCompiler.console(AnalyzingCompiler.scala:233)
[error] 	at sbt.Console.console0$1(Console.scala:64)
[error] 	at sbt.Console.$anonfun$apply$5(Console.scala:74)
[error] 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] 	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
[error] 	at sbt.TrapExit$App.run(TrapExit.scala:258)
[error] 	at java.base/java.lang.Thread.run(Thread.java:829)

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