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/05/24 19:17:00 UTC

[jira] [Commented] (GROOVY-11071) Compiler error related to getAt and interface methods

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

Eric Milles commented on GROOVY-11071:
--------------------------------------

You can re-declare "Object getAt(Key key)" on {{MyMap}} to have it discovered by the current release.

> Compiler error related to getAt and interface methods
> -----------------------------------------------------
>
>                 Key: GROOVY-11071
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11071
>             Project: Groovy
>          Issue Type: Bug
>          Components: class generator
>    Affects Versions: 3.0.17, 4.0.12
>            Reporter: Daniel Huss
>            Assignee: Eric Milles
>            Priority: Major
>
> *Error message:*
> {code:none}
> BUG! exception in phase 'class generation' in source unit '...Reproducer.groovy' At line 11 column 21
> On receiver: myMap with message: getAt and arguments: new Reproducer$Key()
> This method should not have been called. {code}
> *Simple example reproducing the error:*
> {code:groovy}
> import groovy.transform.CompileStatic
> import org.junit.jupiter.api.Test
> @CompileStatic
> class Reproducer {
>     @Test
>     void reproduce() {
>         MyMap myMap = null
>         try {
>             println(myMap[new Key()].toString())
>         } catch (NullPointerException ignored) {
>             // Expected
>         }
>     }
>     static class Key {}
>     static interface SomeMap<SELF extends SomeMap<SELF, K, V>, K, V> {
>         V getAt(K key);
>     }
>     static interface MyMap extends SomeMap<MyMap, Key, Object> {}
> }
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)