[
https://issues.apache.org/jira/browse/GROOVY-11975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077343#comment-18077343
]
Eric Milles edited comment on GROOVY-11975 at 4/30/26 1:47 PM:
---------------------------------------------------------------
So if I write this in Java, I get an error that Object does not have a foo
method.
!image-2026-04-30-08-44-41-897.png!
I need to add a qualifier to the super call to target the interface method. I
think this has to do with future-proofing – a super class adding a foo method
would change the outcome otherwise.
The STC error is directing you to add the qualifier, which would be
"IService.super.save(entity)" in your example.
was (Author: emilles):
So if I write this in Java, I get an error that Object does not have a foo
method.
!image-2026-04-30-08-44-41-897.png!
I need to add a qualifier to the super call to target the interface method. I
think this has to do with future-proofing – a super class adding a foo method
would change the outcome.
The STC error is directing you to add the qualifier, which would be
"IService.super.save(entity)" in your example.
> CLONE - Groovy 5 can not compile super.foo with default interface method
> ------------------------------------------------------------------------
>
> Key: GROOVY-11975
> URL: https://issues.apache.org/jira/browse/GROOVY-11975
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 5.x
> Reporter: Saravanan
> Assignee: Eric Milles
> Priority: Minor
> Attachments: image-2026-04-30-08-44-41-897.png
>
>
> {code:java}
> package com.company.test
> import groovy.transform.CompileStatic
> @CompileStatic
> interface IService {
> default void save(T entity) {
> System.out.println(entity);
> }
> }
> @CompileStatic
> class TestGenericGroovy implements IService {
> void save(String entity) {
> // IService.super.save(entity) // works
> super.save(entity) // doesn't work: Groovyc: [Static type checking] -
> Default method save() requires qualified super
> }
> static void main(String[] args) {
> new TestGenericGroovy().save("test")
> }
> }
> {code}
> This seems to stem from issue GROOVY-10494.
> Now that Groovy supports interfaces natively without traits, it looks like
> this other fix is not necessary
--
This message was sent by Atlassian Jira
(v8.20.10#820010)