You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2026/07/24 23:20:00 UTC
[jira] [Resolved] (GROOVY-12188) Incorrect "abstract method not implemented … same name but different return type" error for a valid covariant override
[ https://issues.apache.org/jira/browse/GROOVY-12188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-12188.
--------------------------------
Fix Version/s: 5.0.8
Resolution: Fixed
> Incorrect "abstract method not implemented … same name but different return type" error for a valid covariant override
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12188
> URL: https://issues.apache.org/jira/browse/GROOVY-12188
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 5.0.7
> Reporter: Octavia Togami
> Assignee: Paul King
> Priority: Major
> Fix For: 5.0.8
>
>
> The following code in a `Repro.groovy` will cause the error:
> {code:groovy}
> abstract class ProviderSpec<T> {
> abstract T someValue()
> }
> abstract class CollectionPropertySpec<C extends Collection<String>> extends ProviderSpec<C> {
> C someValue() { return null }
> static class Nested<T> {
> // This method is required to trigger the bug, for some reason.
> void trigger(Optional<T> p) { p.map { it } }
> }
> }
> class DefaultListPropertyTest extends CollectionPropertySpec<List<String>> {
> }
> {code}
> {code:sh}
> $ groovyc Repro.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Repro.groovy: 2: Abstract method 'T someValue()' is not implemented but a method of the same name but different return type is defined: method 'C someValue()'
> @ line 2, column 5.
> abstract T someValue()
> ^
> 1 error
> {code}
> This worked fine in Groovy 4 and appears to be correct code as it compiles under {{javac}} as well.
> This was shrunk from real code in Gradle, located at https://github.com/gradle/gradle/blob/adbe2eb8a092ed6f92ea3d693d32769b553151e9/platforms/core-configuration/model-core/src/test/groovy/org/gradle/api/internal/provider/CollectionPropertySpec.groovy#L49 .
--
This message was sent by Atlassian Jira
(v8.20.10#820010)