Closed
Description
Compiler version
3.4.2
3.5.1-RC1
Minimized code
enum Foo[F[_, _], A, B]:
case Wrap(f: F[A, B])
def mapF[G[_, _]](h: [X, Y] => F[X, Y] => G[X, Y]): Foo[G, A, B] =
this match
case Wrap(f) => Wrap(h(f))
def test[A, B] =
val m = Map.empty[A, B]
val foo = Foo.Wrap(m)
foo.mapF[[X, Y] =>> List[Map[X, Y]]](
[X] => List(_) // expected compilation error (the polymorphic function should have 2 parameters)
// correct version that works:
// [X, Y] => List(_)
)
Output (click arrow to expand)
% ~/Downloads/scala3-3.5.0-RC1/bin/scalac test.scala
exception occurred while typechecking test.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 -Xno-enrich-error-messages.
while compiling: test.scala
during phase: typer
mode: Mode(ImplicitsEnabled)
library version: version 2.13.12
compiler version: version 3.5.0-RC1
settings:
Exception in thread "main" java.lang.IndexOutOfBoundsException: 1
at scala.collection.LinearSeqOps.apply(LinearSeq.scala:131)
at scala.collection.LinearSeqOps.apply$(LinearSeq.scala:128)
at scala.collection.immutable.List.apply(List.scala:79)
at dotty.tools.dotc.core.Substituters$.substParams(Substituters.scala:153)
at dotty.tools.dotc.core.Substituters$.mapArgs$2(Substituters.scala:160)
at dotty.tools.dotc.core.Substituters$.mapArgs$2(Substituters.scala:160)
at dotty.tools.dotc.core.Substituters$.substParams(Substituters.scala:160)
at dotty.tools.dotc.core.Substituters$.mapArgs$2(Substituters.scala:160)
at dotty.tools.dotc.core.Substituters$.substParams(Substituters.scala:160)
at dotty.tools.dotc.core.Types$Type.substParams(Types.scala:1927)
at dotty.tools.dotc.typer.Typer.$anonfun$34(Typer.scala:1897)
at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1791)
at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1959)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:827)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:974)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:850)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
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:393)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3346)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3371)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3483)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3587)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3633)
at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1377)
at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1381)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3407)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3484)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
at dotty.tools.dotc.typer.Typer.typedPolyFunctionValue(Typer.scala:1901)
at dotty.tools.dotc.typer.Typer.typedPolyFunction(Typer.scala:1869)
...
Expectation
The compiler should report an error, because the polymorphic function literal has wrong number of type parameters.