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

Static members should not be able to access class-level generic types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8-beta-1
    • 2.5.0-alpha-1
    • class generator
    • None

    Description

      The following code compiles, but it shouldn't because T is a non-static generic type, and difference instances of Outer will have different concrete representations of T. Hence it makes no sense that static inner classes should be able to use such generic type variables.

      class Outer<T> {
          T ofoo
          static class Inner {
              T ifoo
          }
      }
      

      Similarly, all the cases below should not compile as well:

      class Test1<T> {
          static T f1
      }
      
      class Test2<T> {
          static foo(T param1) {}
      }
      
      class Test3<T> {
          static foo() {
              T localVar1
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              roshandawrani Roshan Dawrani
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: