Skip to content

Multiple type applications on overloaded method crashes dotc, and different behavior from scalac #3930

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
Jasper-M opened this issue Jan 26, 2018 · 0 comments
Assignees

Comments

@Jasper-M
Copy link
Contributor

Jasper-M commented Jan 26, 2018

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
@odersky odersky self-assigned this Jan 27, 2018
liufengyun added a commit that referenced this issue Feb 13, 2018
Fix #3930: Handle multiple type arguments in overloading resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants