ConstantConditions warning not working properly

Answered

Given the following sample code:

public static void test(Object value) {
if (value instanceof Integer) {
value = Long.valueOf((Integer) value);
}
System.out.println(value);
}

The IDE will warn that v1 is already assigned to that value, but it is not, this code will change the type.

I am using Android Studio, if anyone can test this with the latest IntelliJ to see if it happens the same I will be grateful.

Android Studio 3.5
Build #AI-191.8026.42.35.5791312, built on August 9, 2019
JRE: 1.8.0_202-release-1483-b03 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

0
2 comments

Hello,

I don't get any warnings in IDEA 2019.2.1 with provided example.

0
Avatar
Permanently deleted user

Aha, so Android Studio is still lagging behind :(

 

Thank you.

0

Please sign in to leave a comment.