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

Static compiler incorrectly typechecks extension modules

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.15, 3.0.8
    • Fix Version/s: 4.0.0-beta-1
    • Component/s: Static compilation
    • Labels:
      None
    • Environment:
      macOS 10.15.7
      OpenJDK Zulu 11.0.3
      Groovy 3.0.8
      Gradle 6.8

      Description

      I think I found a bug in static typechecking of extension modules.

      I tested two variants:

      1. Fixed generic: static void getTestString(List<String> self)
        1. In this case the bug affects both method calls and property access e.g. integerList.getTestString() and integerList.testString both compile
      2. With generic constraint: static <S extends String> void getTestStringOrSubclass(List<S> self) 
        1. In this case the bug only affects property access e.g. integerList.getTestStringOrSubclass() doesn't compile but integerList.testStringOrSubclass compiles

      I prepared an example project here: https://github.com/felixscheinost/test-groovy-static-extensions

      Please have a look at https://github.com/felixscheinost/test-groovy-static-extensions/blob/master/src/main/groovy/org/example/App.groovy

       

      Thanks!

        Attachments

        1. screenshot-1.png
          56 kB
          Eric Milles
        2. screenshot-2.png
          62 kB
          Eric Milles

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              fesc Felix Scheinost
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: