IDEA-209947 Basic explanations for instanceof

GitOrigin-RevId: 86697e1b8f0a1d905c8b17b732bb01f045e4d4b6
This commit is contained in:
Tagir Valeev
2019-04-28 16:36:05 +03:00
committed by intellij-monorepo-bot
parent 8d1f7ad7c3
commit 137792b1c3
5 changed files with 95 additions and 5 deletions
@@ -0,0 +1,14 @@
/*
Value is always false (s instanceof Integer)
Type of 's' is exactly String (s)
Type of 's' is known from line #10 (s instanceof String)
*/
import java.util.List;
class Test {
void test(Object s) {
if (s instanceof String) {
if (<selection>s instanceof Integer</selection>) {}
}
}
}
@@ -0,0 +1,12 @@
/*
Value is always false (s instanceof String)
Value 's' is always 'null' (s)
's == null' was established from condition (s == null)
*/
import java.util.List;
class Test {
void test(Object s) {
if (s == null && <selection>s instanceof String</selection>) {}
}
}
@@ -0,0 +1,14 @@
/*
Value is always true (s instanceof CharSequence)
Type of 's' is exactly String (s)
Type of 's' is known from line #10 (s instanceof String)
*/
import java.util.List;
class Test {
void test(Object s) {
if (s instanceof String) {
if (<selection>s instanceof CharSequence</selection>) {}
}
}
}