Skip to content

Compiler crash after adding an using clause to an otherwise ambigous def that returns a polymorphic function #20176

Closed
@arainko

Description

@arainko

Compiler version

3.3.3, 3.4.1, 3.4.2-RC1, 3.5.0-RC1-bin-20240411-62e0641-NIGHTLY

Minimized code

//> using scala 3.5.0-RC1-bin-20240411-62e0641-NIGHTLY

type Accumulator[A]

object Accumulator {

  val usage = 
    use[Int]:
      "asd"

  inline def use[A](using DummyImplicit): [B] => Any => Any = ???

  inline def use[A]: [B] => Any => Any = ???
}

Output (click arrow to expand)

Compiling project (Scala 3.5.0-RC1-bin-20240411-62e0641-NIGHTLY, JVM (21))

  exception occurred while typechecking /home/aleksander/Repos/repro/repro.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: /home/aleksander/Repos/repro/repro.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.5.0-RC1-bin-20240411-62e0641-NIGHTLY-git-62e0641
            settings: -bootclasspath /home/aleksander/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.0-RC1-bin-20240411-62e0641-NIGHTLY/scala3-library_3-3.5.0-RC1-bin-20240411-62e0641-NIGHTLY.jar:/home/aleksander/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -classpath /home/aleksander/Repos/repro/.scala-build/.bloop/repro_3200b05eac/bloop-internal-classes/main-bgSPdJQFRH2qlXQgS1jnIg==:/home/aleksander/Repos/repro/.scala-build/.bloop/repro_3200b05eac/bloop-internal-classes/main-TVnHSMicQ1SKCGSnzDM8eA== -d /home/aleksander/Repos/repro/.scala-build/.bloop/repro_3200b05eac/bloop-internal-classes/main-bgSPdJQFRH2qlXQgS1jnIg== -java-output-version 21 -sourceroot /home/aleksander/Repos/repro

Error compiling project (Scala 3.5.0-RC1-bin-20240411-62e0641-NIGHTLY, JVM (21))
Error: Unexpected error when compiling repro_3200b05eac: java.lang.AssertionError: assertion failed: asTerm called on not-a-Term val <none>
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.Symbols$Symbol.asTerm(Symbols.scala:186)
        at dotty.tools.dotc.typer.Applications.$anonfun$35(Applications.scala:2278)
        at scala.collection.immutable.List.flatMap(List.scala:293)
        at dotty.tools.dotc.typer.Applications.resolveMapped(Applications.scala:2274)
        at dotty.tools.dotc.typer.Applications.resolveMapped$(Applications.scala:367)
        at dotty.tools.dotc.typer.Typer.resolveMapped(Typer.scala:120)
        at dotty.tools.dotc.typer.Applications.resolve$1(Applications.scala:1974)
        at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:2016)
        at dotty.tools.dotc.typer.Applications.resolveOverloaded$(Applications.scala:367)
        at dotty.tools.dotc.typer.Typer.resolveOverloaded(Typer.scala:120)
        at dotty.tools.dotc.typer.Applications.resolveMapped(Applications.scala:2296)
        at dotty.tools.dotc.typer.Applications.resolveMapped$(Applications.scala:367)
        at dotty.tools.dotc.typer.Typer.resolveMapped(Typer.scala:120)
        at dotty.tools.dotc.typer.Applications.resolveOverloaded1(Applications.scala:2158)
        at dotty.tools.dotc.typer.Applications.resolve$1(Applications.scala:1977)
        at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:2018)
        at dotty.tools.dotc.typer.Applications.resolveOverloaded$(Applications.scala:367)
        at dotty.tools.dotc.typer.Typer.resolveOverloaded(Typer.scala:120)
        at dotty.tools.dotc.typer.Typer.adaptOverloaded$1(Typer.scala:3743)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4379)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3701)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3413)
        at dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:1186)
        at dotty.tools.dotc.typer.Applications.typedTypeApply$(Applications.scala:367)
        at dotty.tools.dotc.typer.Typer.typedTypeApply(Typer.scala:120)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3157)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3221)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3413)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:973)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1133)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:367)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:120)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3137)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3221)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3413)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1700)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1690)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1700)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1956)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1956)
        at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1964)
        at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1983)
        at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1984)
        at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1995)
        at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1738)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1744)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:804)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:955)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:831)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:178)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:398)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3084)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3109)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3220)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3324)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3370)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2814)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3125)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3129)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3220)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3324)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3370)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2814)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3125)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3129)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3220)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3324)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3370)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2947)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3171)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3221)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3298)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3302)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3413)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:503)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:684)
        at scala.collection.immutable.List$.from(List.scala:681)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:319)
        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:312)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:351)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:361)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:361)
        at dotty.tools.dotc.Run.compileSources(Run.scala:262)
        at dotty.tools.dotc.Run.compile(Run.scala:247)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
        at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:133)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$7(BloopHighLevelCompiler.scala:155)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:71)
        at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:70)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$6(BloopHighLevelCompiler.scala:155)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81)
        at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
        at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
        at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions