You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
compiler should generate error "method foo1 in class C must be called with () argument" for inherited nullary method without arguments that has extra overloaded function in child class #21207
I am using the language specification at 1 & 2 & 3.
Use the code below:
(It might be convenient to use worksheet to see the evaluation result)
traitT { // NOTE: it can abstract class or class, it doesn't matterdeffoo1():Int=1deffoo2(x: Int):Int=33
}
classCextendsT {
deffoo1(x: Int):Int=11deffoo2():Int=33deffoo3():Int=2deffoo3(x: Int):Int=22
}
valc=newCvalx1= c.foo1
valx2= c.foo2
valx3= c.foo3
Notice that c.foo1 compiles fine and evaluates to 1
However for c.foo2 and c.foo3 compiler generates a syntax error: method foo3 in class C must be called with () argument
According to spec the compiler should also generate an error for c.foo1: method foo1 in class C must be called with () argument
The exclusion can be Java methods, but foo1 is not defined in Java and not overridden.
Excluded from this rule are methods that are defined in Java or that override methods defined in Java.
Note that if you remove def foo1(x: Int): Int = 11 then the error IS generated.
It seems like the check if foo1 has some parameters somehow interleaves with overloading resolution and is done before def foo1(x: Int): Int is discarded