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
assertion failure in superaccessors #5969
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5969?orig=1 |
@paulp said:
|
@retronym said: class C1
class C2
class A {
def f(x: Any) = x
def g(x: C1): String = "A"
def g(x: C2): String = "B"
def hof(x: String => Any) {}
class X[A]() {
def this(a: A) = this()
def map[B](f: A => Any): Any = ??? // remove type parameter => avoid crash
}
def crash() = hof { x =>
if (false) new X(g("")) else new X[C1]().map(g)
// Other lubby situations crash:
//
// (true: Boolean) match {
// case false => new X(g("")); case true => new X[C1]().map(g)
// }
// try new X(g("")) catch { case _ => new X[C1]().map(g) }
// List(new X(g("")), new X[C1]().map(g))
}
// No crash if the argument isn't a function
// def nocrash1() = identity {
// if (false) new X(g("")) else new X[C1]().map(g)
// }
} The error is buffered into a Context deep down in type checking, but it doesn't get reported later on. It's pretty hard to see through the thicket of |
@som-snytt said: |
@retronym said: |
This was a difficult minimization. g must be overloaded; the expression must be typed as an argument; and both legs of the if as well as the call to map appear to be necessary. Remove any of the above, and one sees the appropriate error message - List(g(x)) is attempting to call g with a String rather than one of the types upon which it is overloaded.
The text was updated successfully, but these errors were encountered: