summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java')
-rw-r--r--java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java
index 8be16fc1db85..8ba3ea4f8037 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java
@@ -94,4 +94,96 @@ class C {
void asLongs(Integer i) {
long l = (long) i;
}
+
+ void foo(Object o) {}
+ public void cast2(Byte operand) {
+ foo((<warning descr="Casting 'operand' to 'byte' is redundant">byte</warning>)operand);
+ foo((short)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Byte' to 'char'">(char)operand</error>);
+ foo((int)operand);
+ foo((long)operand);
+ foo((float)operand);
+ foo((double)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Byte' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Short operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Short' to 'byte'">(byte)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'short' is redundant">short</warning>)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Short' to 'char'">(char)operand</error>);
+ foo((int)operand);
+ foo((long)operand);
+ foo((float)operand);
+ foo((double)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Short' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Character operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Character' to 'byte'">(byte)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Character' to 'short'">(short)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'char' is redundant">char</warning>)operand);
+ foo((int)operand);
+ foo((long)operand);
+ foo((float)operand);
+ foo((double)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Character' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Integer operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'byte'">(byte)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'short'">(short)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'char'">(char)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'int' is redundant">int</warning>)operand);
+ foo((long)operand);
+ foo((float)operand);
+ foo((double)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Integer' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Long operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'byte'">(byte)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'short'">(short)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'char'">(char)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'int'">(int)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'long' is redundant">long</warning>)operand);
+ foo((float)operand);
+ foo((double)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Float operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'byte'">(byte)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'short'">(short)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'char'">(char)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'int'">(int)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'long'">(long)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'float' is redundant">float</warning>)operand);
+ foo((double)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Float' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Double operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'byte'">(byte)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'short'">(short)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'char'">(char)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'int'">(int)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'long'">(long)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'float'">(float)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'double' is redundant">double</warning>)operand);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Double' to 'boolean'">(boolean)operand</error>);
+ }
+ public void cast2(Boolean operand) {
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'byte'">(byte)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'short'">(short)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'char'">(char)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'int'">(int)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'long'">(long)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'float'">(float)operand</error>);
+ foo(<error descr="Inconvertible types; cannot cast 'java.lang.Boolean' to 'double'">(double)operand</error>);
+ foo((<warning descr="Casting 'operand' to 'boolean' is redundant">boolean</warning>)operand);
+ }
+ public void cast2(Object operand) {
+ foo((<warning descr="Casting 'operand' to 'byte' is redundant">byte</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'short' is redundant">short</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'char' is redundant">char</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'int' is redundant">int</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'long' is redundant">long</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'float' is redundant">float</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'double' is redundant">double</warning>)operand);
+ foo((<warning descr="Casting 'operand' to 'boolean' is redundant">boolean</warning>)operand);
+ }
} \ No newline at end of file