Possible bug in IC-145.258


Hi All.

I have encountered code like this

public class Main {
public static void main(String[] cmd) {
Object value = "Hello ";

// IntelliJ highlights following line with message
// "Operator '+' cannot be applied to 'java.lang.Object', 'java.lang.String'"
value += "World";

// But this one is fine
value = value + "!";

You can see that `value += "World"` is highlighted as an error. That looks to me like a bug, but perhaps
I do not understand something here, in which case please let me why this is correct.

Dmitri Priimak

Comment actions Permalink

Thanks for the report, I've submitted a bug at https://youtrack.jetbrains.com/issue/IDEA-154209.

Comment actions Permalink

The code doesn't compile with javac 6, was fixed later but IDEA was not updated accordingly.


Please sign in to leave a comment.