Can anybody explain to me why the following block of code is highlighted as a mistake in Android Studio?
The IDE is saying elem instanceof SubtypeB
is always false - is this just a mistake by the inspector or is this a real language detail I need to learn about?. Can I safely suppress the warning and keep the current code?
Example code:
for (Parcelable elem : list) {
try {
listOfSubtypeA.add( (SubtypeA) elem );
} catch (ClassCastException cce) {
//Line below is highlighted as always false
if (elem instanceof SubtypeB) {
... //just logging
}
}
}