Description
Compiler version
3.0.1-RC2
Minimized code
object Foo:
inline def unapply(using String)(i: Int): Some[Int] = Some(i)
given String = ""
val i = 10 match
case Foo(x) => x
Output (click arrow to expand)
Exception in thread "main" java.util.NoSuchElementException: head of empty list
at scala.collection.immutable.Nil$.head(List.scala:662)
at scala.collection.immutable.Nil$.head(List.scala:661)
at dotty.tools.dotc.typer.Inliner.computeParamBindings(Inliner.scala:522)
at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:745)
at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:153)
at dotty.tools.dotc.typer.Inliner$.$anonfun$4(Inliner.scala:207)
at dotty.tools.dotc.ast.tpd$.DefDef(tpd.scala:285)
at dotty.tools.dotc.typer.Inliner$.inlinedUnapply(Inliner.scala:208)
at dotty.tools.dotc.typer.Typer$$anon$1.transform(Typer.scala:1588)
at dotty.tools.dotc.typer.Typer.caseRest$1(Typer.scala:1615)
at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:1633)
at dotty.tools.dotc.typer.Typer.typedCases$$anonfun$1(Typer.scala:1563)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:92)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:108)
at dotty.tools.dotc.typer.Typer.typedCases(Typer.scala:1565)
at dotty.tools.dotc.typer.Typer.$anonfun$20(Typer.scala:1555)
at dotty.tools.dotc.typer.Applications.harmonic(Applications.scala:2186)
at dotty.tools.dotc.typer.Applications.harmonic$(Applications.scala:316)
at dotty.tools.dotc.typer.Typer.harmonic(Typer.scala:106)
at dotty.tools.dotc.typer.Typer.typedMatchFinish(Typer.scala:1555)
at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:1511)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2709)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2758)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1394)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1381)
at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1394)
at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1546)
at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
at dotty.tools.dotc.typer.Namer.typedAheadRhs$2(Namer.scala:1546)
at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1554)
at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1581)
at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1582)
at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1593)
at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1602)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:699)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:826)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:727)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2637)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2662)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2849)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2899)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2354)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2683)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2687)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2757)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2849)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2899)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2477)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2728)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2758)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2823)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2827)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2943)
at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
at dotty.tools.repl.REPLFrontEnd.runOn(ReplFrontEnd.scala:23)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
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$5(Run.scala:216)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
at dotty.tools.dotc.Run.compileUnits(Run.scala:231)
at dotty.tools.dotc.Run.compileUnits(Run.scala:172)
at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:152)
at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:162)
at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:249)
at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:212)
at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:146)
at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:149)
at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:168)
at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:149)
at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:115)
at dotty.tools.repl.Main$.main(Main.scala:6)
at dotty.tools.repl.Main.main(Main.scala)
The code compiles successfully if we either make unapply
non-inlined or put the contextual parameter at the end instead.