Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-11071

Compiler error related to getAt and interface methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.17, 4.0.12
    • 5.0.0-alpha-1
    • class generator
    • None

    Description

      Error message:

      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. 

      Simple example reproducing the error:

      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> {}
      }
       

      Attachments

        Activity

          People

            emilles Eric Milles
            hussdl Daniel Huss
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: