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

MalformedParameterizedTypeException when bounded generic attribute without visibility modifier

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.3
    • Fix Version/s: 2.3.7, 2.4.0-beta-3
    • Component/s: None
    • Labels:

      Description

      This code fails in runtime with MalformedParameterizedTypeException - run main to try it out:

      class Dependency<T> {
      }
      
      class Something<T extends Number> {
          Dependency<? super T> dependency
      
          static main(String[] args) {
              new Something<Integer>()
          }
      }
      

      However, it does not fail if a visibility modifier is added before dependency attribute - private, protected, public or @PackageScope transformation.

      This also fails with MalformedParameterizedTypeException and I don't know how to make it work:

      class Something<T extends Number> {
          void someMethod(Dependency<? super T> dependency) {
          }
      
          static main(String[] args) {
              new Something<Integer>()
          }
      }
      

      Do you know what may be the cause? Do you know of any workaround for the second case?

        Attachments

          Activity

            People

            • Assignee:
              blackdrag Jochen Theodorou
              Reporter:
              pbetkier Piotr Betkier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: