-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b106
-
unknown
-
generic
-
Verified
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.
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.
- duplicates
-
JDK-8025494 javac inference - shadowing compile error
-
- Closed
-
- relates to
-
JDK-8023520 Add missing test for JDK-7118412
-
- Resolved
-
-
JDK-8035259 javac, incorrect shadowing of classes vs type parameters
-
- Closed
-
-
JDK-8193583 Generic types have to be casted to proper type
-
- Closed
-
-
JDK-5060485 The scope of a class type parameter is too wide
-
- Closed
-