Details
-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
generic
-
generic
Description
ADDITIONAL SYSTEM INFORMATION :
generic
JDK15+
A DESCRIPTION OF THE PROBLEM :
see the code:
Type1 a = ...;
Type2 b = a instanceof Type2 c ? c : null;
Type3 c = ...;
[Phenomenon]
The Variable c in line 2 is used in and only in the second line, and it will not have any impact on subsequent code。
[Recommendation]
so, we can remove the c in line 2 if possible, and at the same time, it can avoid misunderstandings about the naming of subsequent code.
Next are several possible grammars:
var b = a instanceof Type2 | null;
or
var b = a instanceof -> Type2;
or
var b = a -> Type2;
or
Type2 b = a | null;
generic
JDK15+
A DESCRIPTION OF THE PROBLEM :
see the code:
Type1 a = ...;
Type2 b = a instanceof Type2 c ? c : null;
Type3 c = ...;
[Phenomenon]
The Variable c in line 2 is used in and only in the second line, and it will not have any impact on subsequent code。
[Recommendation]
so, we can remove the c in line 2 if possible, and at the same time, it can avoid misunderstandings about the naming of subsequent code.
Next are several possible grammars:
var b = a instanceof Type2 | null;
or
var b = a instanceof -> Type2;
or
var b = a -> Type2;
or
Type2 b = a | null;