Non-errors show up as errors in generics

Answered

Using 2021.2.3 Community Edition, with Java 11.

The following is a very simple test code to demonstrate the problem.  It compiles just fine.  But the "Problems" lists "Operator '<' cannot be applied to 'Time', 'long'".  I could not find any way to get rid off this "error".  

public class SimpleTest<Time extends Long> {
public boolean lessThanMax(Time a) {
return a < Long.MAX_VALUE;
}
}
0
3 comments

Hello, 

Please follow the similar issue:

https://youtrack.jetbrains.com/issue/IDEA-217230

 

Thank you for the report.

1

The similar issue with the link is not really similar to the simple example above.  This generic does not use wild card.  If you could please copy and paste the code in the editor, you'd see the problem.  I tried to be as compact as possible with the example.

Even though everything compiles, I can't see the actual problems while editing the two classes that give me 85 different errors due to the problem demonstrated here.  Also, every time I try to check it in to version control, it reports errors.  

The code analyzer reports errors with this code.  The error being reported is not in the options of code analyzer to change.  Therefore, there is no way to disable the 'error'.

0

Hello,

The code sample that you've provided is added to the issue in private comment to the responsible developer, so the described case will be considered. Thank you

0

Please sign in to leave a comment.