You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/12/21 22:30:00 UTC
[jira] [Commented] (GROOVY-11256) Fail to identify direct call of abstract method
[ https://issues.apache.org/jira/browse/GROOVY-11256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17799596#comment-17799596 ]
Eric Milles commented on GROOVY-11256:
--------------------------------------
Usage of "Type.super.method()" was recently opened up for interfaces with static and private methods. Groovy 3 tells me "The usage of 'Type.this' and 'Type.super' is only allowed in nested/inner classes."
> Fail to identify direct call of abstract method
> -----------------------------------------------
>
> Key: GROOVY-11256
> URL: https://issues.apache.org/jira/browse/GROOVY-11256
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Minor
>
> I have the following ill-typed program
> {code}
> interface A {
> int m();
> }
> class C implements A {
> public int m() { return 1; }
> void test() {
> A.super.m();
> }
> }
> public class Test {
> public static void main(String[] args) {
> new C().test();
> }
> }
> {code}
> h3. Actual behavior
> The program compiles with and produces:
> {code}
> Exception in thread "main" java.lang.AbstractMethodError: 'int A.m()'
> at C.test(Test.groovy:8)
> at Test.main(Test.groovy:14)
> {code}
> h3. Expected behavior
> Reject the program with:
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Test.groovy: 8: [Static type checking] - Abstract method m() cannot be called directly
> @ line 8, column 9.
> A.super.m();
> ^
> 1 error
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)