switch expressions: check old style breaks & switch chains during compatibility checks

IDEA-CR-40239
This commit is contained in:
Anna.Kozlova
2018-11-22 18:31:25 +01:00
parent 62197fa2c8
commit 1658b14f3c
3 changed files with 64 additions and 10 deletions
@@ -37,5 +37,47 @@ no instance(s) of type variable(s) exist so that Integer conforms to String">()
break () -> <error descr="Bad return type in lambda expression: int cannot be converted to String">1</error>;
}
};
String s7 = switch (i) {
case 1: {
break <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">1</error>;
}
default: {
int i1 = switch (0) {
default -> {
break 1;
}
};
break "";
}
};
}
void switchChain(final int i) {
String s = switch (i) {
default -> switch (0) {
default -> {
break <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">1</error>;
}
};
};
String s1 = switch (i) {
default -> {
break switch (0) {
default -> {
break <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">1</error>;
}
};
}
};
String s2 = switch (i) {
default: {
break switch (0) {
default -> {
break <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">1</error>;
}
};
}
};
}
}