Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7118412

Shadowing of type-variables vs. member types

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b106
    • CPU:
      unknown
    • OS:
      generic
    • Verification:
      Verified

      Description

      5060485 made an attempt at fixing an issue with shadowing of type-variables w.r.t. member type declarations. Unfortunately the fix is incomplete - the following code works:

      public class X<Y> {

        static public class Y {}

        static public class Y1 <T extends X<Y>> {
        }

      }

      Showing that, in the declaration of Y1, Y is correctly resolved to the nested class, not the type-parameter. However there are cases in which javac still gets shadowing wrong:

      class Test<T> {
          static class T { }
          static T q;
      }

      This fails with the following message:

      TestBug.java:13: non-static class T cannot be referenced from a static context
          static T q;
                 ^
      1 error

      Revealing that javac is resolving T to the type-variable type rather than to the class type.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              emc Eric Mccorkle
              Reporter:
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: