[ 
https://issues.apache.org/jira/browse/GROOVY-12188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18098886#comment-18098886
 ] 

ASF GitHub Bot commented on GROOVY-12188:
-----------------------------------------

paulk-asert opened a new pull request, #2733:
URL: https://github.com/apache/groovy/pull/2733

   … of classgen order
   
   Since GROOVY-10687, a top-level class whose inner classes contain a closure 
is generated after its nest members, which can place it after its own subclass 
in the classgen order. The abstract-method check in ClassCompletionVerifier 
relied on the covariant bridge method that Verifier adds to the declaring 
class, so verifying a subclass first raised a spurious "same name but different 
return type" error. Recognise a covariant override directly instead; genuinely 
incompatible return types are still rejected by Verifier's covariant-method 
check.




> 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
>
> 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)

Reply via email to