Skip to content

FatalError on PolyFunction in macro #14180

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
Adam-Vandervorst opened this issue Dec 28, 2021 · 3 comments · Fixed by #14222
Closed

FatalError on PolyFunction in macro #14180

Adam-Vandervorst opened this issue Dec 28, 2021 · 3 comments · Fixed by #14222

Comments

@Adam-Vandervorst
Copy link

Adam-Vandervorst commented Dec 28, 2021

Compiler version

3.1.2-RC1-bin-20211222-c94b333-NIGHTLY

Minimized code

// poly_inline.scala
inline def foreach[T <: Tuple]
  (inline xs: T, inline f: [A] => (a: A) => Unit) = 
  ${ foreachImpl('{xs}, '{f}) }

@main def example =
  foreach(1 *: 2 *: EmptyTuple, [V] => (v: V) => println(v))

// macro_file.scala
import scala.quoted._

def foreachImpl[T <: Tuple : Type]
  (xs: Expr[T], f: Expr[[A] => A => Unit])
  (using Quotes): Expr[Unit] =
  xs match
    case '{ EmptyTuple } => '{ () }
    case '{ $t: Tuple1[t1] } => '{ $f($t._1) }
    case '{ $t: Tuple2[t1, t2] } => '{ $f($t._1); $f($t._2) }
    ...

Output

  foreach(1 *: 2 *: EmptyTuple, [V] => (v: V) => println(v))
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
undefined: {
  final class $anon() extends Object.<init>(), scala.this.PolyFunction {
    def apply[V >: scala.this.Nothing <: scala.this.Any](v: V): 
      scala.this.Unit(inf)
     = scala.this.Predef.println(v)
  }
  (new $anon.<init>():
    scala.this.PolyFunction{apply[V](v: V): scala.this.Unit}(inf)
  )
}.<none> # -1: TermRef(RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),trait PolyFunction),apply,PolyType(List(V), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), MethodType(List(v), List(TypeParamRef(V)), TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)))),<none>) at inlining
 This location contains code that was inlined from macro_file.scala:25
 This location contains code that was inlined from macro_file.scala:25
 one error found
Click the arrow to see the full stack trace.

dotty.tools.FatalError:
at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:295)
at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:19)
at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:119)
at dotty.tools.dotc.ast.tpd$TypedTreeCopier.Apply(tpd.scala:615)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1389)
at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1493)
at scala.collection.immutable.List.mapConserve(List.scala:472)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1493)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1491)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1403)
at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:121)
at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:60)
at scala.quoted.runtime.impl.QuotesImpl.unpickleExpr(QuotesImpl.scala:3002)
at poly_inline.macro_file$package$.foreachImpl(macro_file.scala:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretedStaticMethodCall$$anonfun$1$$anonfun$1(Splicer.scala:375)
at dotty.tools.dotc.transform.Splicer$Interpreter.stopIfRuntimeException(Splicer.scala:439)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretedStaticMethodCall$$anonfun$1(Splicer.scala:375)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretTree(Splicer.scala:268)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretTree$$anonfun$2(Splicer.scala:288)
at dotty.tools.dotc.transform.Splicer$.$anonfun$2(Splicer.scala:56)
at scala.Option.fold(Option.scala:263)
at dotty.tools.dotc.transform.Splicer$.splice(Splicer.scala:56)
at dotty.tools.dotc.typer.Inliner.dotty$tools$dotc$typer$Inliner$$expandMacro(Inliner.scala:1821)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedApply(Inliner.scala:1599)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2802)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2865)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1682)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:62)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2807)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2865)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1682)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:1052)
at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:160)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:86)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:103)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:111)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1466)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1477)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:94)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:72)
at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:44)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
at dotty.tools.dotc.transform.Inlining.runOn(Inlining.scala:48)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:287)
at dotty.tools.dotc.Run.compileUnits(Run.scala:226)
at dotty.tools.dotc.Driver.finish(Driver.scala:60)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:40)
at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:175)
at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:173)
at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:459)
at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:414)
at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:501)
at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:401)
at sbt.internal.inc.Incremental$.apply(Incremental.scala:167)
at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2357)
at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2314)
at sbt.internal.io.Retry$.apply(Retry.scala:46)
at sbt.internal.io.Retry$.apply(Retry.scala:28)
at sbt.internal.io.Retry$.apply(Retry.scala:23)
at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2310)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
at sbt.std.Transform$$anon$4.work(Transform.scala:68)
at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
at sbt.Execute.work(Execute.scala:291)
at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
dotty.tools.FatalError:
at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:295)
at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:19)
at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:119)
at dotty.tools.dotc.ast.tpd$TypedTreeCopier.Apply(tpd.scala:615)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1389)
at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1403)
at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:106)
at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:121)
at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:60)
at scala.quoted.runtime.impl.QuotesImpl.unpickleExpr(QuotesImpl.scala:3002)
at poly_inline.macro_file$package$.foreachImpl(macro_file.scala:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretedStaticMethodCall$$anonfun$1$$anonfun$1(Splicer.scala:375)
at dotty.tools.dotc.transform.Splicer$Interpreter.stopIfRuntimeException(Splicer.scala:439)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretedStaticMethodCall$$anonfun$1(Splicer.scala:375)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretTree(Splicer.scala:268)
at dotty.tools.dotc.transform.Splicer$Interpreter.interpretTree$$anonfun$2(Splicer.scala:288)
at dotty.tools.dotc.transform.Splicer$.$anonfun$2(Splicer.scala:56)
at scala.Option.fold(Option.scala:263)
at dotty.tools.dotc.transform.Splicer$.splice(Splicer.scala:56)
at dotty.tools.dotc.typer.Inliner.dotty$tools$dotc$typer$Inliner$$expandMacro(Inliner.scala:1821)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedApply(Inliner.scala:1599)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2802)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2865)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1682)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:62)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2807)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2865)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Inliner$InlineTyper.typedUnadapted(Inliner.scala:1682)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:1052)
at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:160)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:86)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:103)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:111)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1466)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1477)
at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:94)
at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:72)
at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:44)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
at dotty.tools.dotc.transform.Inlining.runOn(Inlining.scala:48)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:287)
at dotty.tools.dotc.Run.compileUnits(Run.scala:226)
at dotty.tools.dotc.Driver.finish(Driver.scala:60)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:40)
at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:175)
at sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:173)
at sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:459)
at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
at sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:414)
at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:501)
at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:401)
at sbt.internal.inc.Incremental$.apply(Incremental.scala:167)
at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2357)
at sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2314)
at sbt.internal.io.Retry$.apply(Retry.scala:46)
at sbt.internal.io.Retry$.apply(Retry.scala:28)
at sbt.internal.io.Retry$.apply(Retry.scala:23)
at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2310)
at scala.Function1.$anonfun$compose$1(Function1.scala:49)
at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
at sbt.std.Transform$$anon$4.work(Transform.scala:68)
at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
at sbt.Execute.work(Execute.scala:291)
at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

Expectation

Still on the quest to unroll a for-loop, trying to implement #13958 (reply in thread).

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 4, 2022

Minimized

import scala.quoted._
def impl(using Quotes): Expr[Unit] =
  '{ ([V] => (v: V) => println(v)).apply[Int](2) }
inline def foo = ${ impl }
def example = foo
2 |def example = foo
  |              ^^^
  |undefined: {
  |  final class $anon() extends Object(), PolyFunction {
  |    def apply[V >: Nothing <: Any](v: V): Unit = println(v)
  |  }
  |  (new $anon():([V] => (V) => Unit))
  |}.<none> # -1: TermRef(RefinedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),PolyFunction),apply,PolyType(List(V), List(TypeBounds(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any))), MethodType(List(v), List(TypeParamRef(V)), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Unit)))),<none>) at inlining
  | This location contains code that was inlined from Bar.scala:3
  | This location contains code that was inlined from Bar.scala:3

@nicolasstucki
Copy link
Contributor

@smarter are there going to be more changes in the encoding of PolyFunction?

@smarter
Copy link
Member

smarter commented Jan 4, 2022

We might introduce a way to represent polymorphic by-names, but it's unlikely we'll change the current encoding given the backwards compatibility headaches that would create.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 6, 2022
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
@Kordyjan Kordyjan added this to the 3.1.2 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.

4 participants