Closed
Description
Inspired by scala/bug#10628.
I'm not sure if I should create 2 separate issues or not, so apologies in advance.
The following invalid code:
object A {
def a[F](x: Int) = 0
def a[F](x: String) = 0
}
A.a[Int][String](0)
crashes the compiler with:
java.lang.AssertionError: assertion failed
at scala.Predef$.assert(Predef.scala:204)
at dotty.tools.dotc.typer.Applications.$anonfun$resolveOverloaded$5(Applications.scala:1390)
at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:1303)
at dotty.tools.dotc.typer.Applications.$anonfun$resolveOverloaded$5(Applications.scala:1392)
at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:1303)
at dotty.tools.dotc.typer.Applications.$anonfun$resolveOverloaded$1(Applications.scala:1289)
at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:1244)
at dotty.tools.dotc.typer.Applications.resolveOverloaded$(Applications.scala:1244)
at dotty.tools.dotc.typer.Typer.resolveOverloaded(Typer.scala:82)
at dotty.tools.dotc.typer.Typer.adaptOverloaded$1(Typer.scala:2019)
at dotty.tools.dotc.typer.Typer.adaptInterpolated(Typer.scala:2417)
at dotty.tools.dotc.typer.Typer.$anonfun$adapt$3(Typer.scala:1962)
at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:1955)
at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:1955)
at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1790)
at dotty.tools.dotc.reporting.trace$.op1$2(trace.scala:25)
at dotty.tools.dotc.reporting.trace$.apply(trace.scala:26)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1786)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1847)
at dotty.tools.dotc.typer.Applications.$anonfun$typedTypeApply$1(Applications.scala:792)
at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
at dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:789)
at dotty.tools.dotc.typer.Applications.typedTypeApply$(Applications.scala:789)
at dotty.tools.dotc.typer.Typer.typedTypeApply(Typer.scala:82)
...
The same for the following valid code:
class Apply { def apply[A](x: Int) = 1 }
object A {
def a[F] = new Apply
def a[F](x: String) = 0
}
A.a[String][Int](3)
Also, given the previous definitions of Apply
and A
, the following doesn't compile with dotc but does with scalac:
A.a[String](3) // scala 2.12.4 returns 1
Metadata
Metadata
Assignees
Labels
No labels