-
Notifications
You must be signed in to change notification settings - Fork 1.1k
AbstractMethodError with anonymous class #7597
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
Comments
The error is not with anonymous class here. I get the same error error even with the below code (which is what the FrontEnd phase of the dotty compiler generates even for the code mentioned in the issue)
The problem is the dotty compiler compiles this code but it should have thrown an error saying that that The Scalac compiler throws the expected error
|
Documenting my observations so far
|
Documenting further observations when the running the program
Printing the value of Actual output
Expected Output
|
I'm not sure we can throw the same error as Scalac, in the current architecture: On Gitter, I proposed to fix this by using subtype checking, instead of going by signatures. If member |
Notwithstanding all I said, I wonder if this code should be rejected (tho it's rejected in Scala 2): scala> object Bar {
| def foo[A >: String]: Function1[String, Int] = new Function1[String, Int] {
| def apply(a: A): Int = 1
| }
| }
2 | def foo[A >: String]: Function1[String, Int] = new Function1[String, Int] {
| ^
|object creation impossible, since def apply(v1: String): Int is not defined
|(Note that T1 does not match A) I wonder because this can be fixed via manual bridging, tho the resulting code is a bit silly object Bar {
def foo[A >: String]: Function1[String, Int] = new Function1[String, Int] {
def apply(a: A): Int = 1
def apply(x: String): Int = apply(x: A)
}
} or via scala> object Bar {
def foo[A >: String]: Function1[String, Int] = new Function1[A, Int] {
def apply(a: A): Int = 1
}
} and this makes me start to wonder if erasing abstract types in negative positions should use the lower bound instead... tho that sounds extremely invasive (and I'd guess wrong somewhere else?). |
@Blaisorblade should this the expected error? |
@ashwinbhaskar yes, that's what I'd expect from tuning step 1.8. |
…ng and overridden do not match
@Blaisorblade Now coming to I tried to change this line to
|
Hm, this is tricky. One must design together I'm now less sure about the code calling One idea is to try changing |
Going back to #7597 (comment), |
Fix #7597: Refine checks whether a deferred term member is implemented
minimized code
runtime error
expectation
Some type error that
apply
is not implementedThe text was updated successfully, but these errors were encountered: