Fix ClassCastException introduced in https://github.com/JetBrains/kotlin/commit/8d501bd7f4f1093bcf29165755aff3f2a945c88a
This commit is contained in:
@@ -96,8 +96,12 @@ public final class WhenChecker {
|
|||||||
) {
|
) {
|
||||||
JetSimpleNameExpression reference = getReference(whenExpression.getExpression());
|
JetSimpleNameExpression reference = getReference(whenExpression.getExpression());
|
||||||
if (reference == null) return false;
|
if (reference == null) return false;
|
||||||
|
|
||||||
DeclarationDescriptor target = trace.get(BindingContext.REFERENCE_TARGET, reference);
|
DeclarationDescriptor target = trace.get(BindingContext.REFERENCE_TARGET, reference);
|
||||||
if (target == null) return false;
|
if (!(target instanceof VariableDescriptor)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ClassDescriptor classDescriptor = trace.get(BindingContext.OBJECT_DECLARATION_CLASS, (VariableDescriptor) target);
|
ClassDescriptor classDescriptor = trace.get(BindingContext.OBJECT_DECLARATION_CLASS, (VariableDescriptor) target);
|
||||||
return classDescriptor == enumEntry;
|
return classDescriptor == enumEntry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ enum class Direction {
|
|||||||
EAST
|
EAST
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
class object {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum class Color(val rgb : Int) {
|
enum class Color(val rgb : Int) {
|
||||||
RED : Color(0xFF0000)
|
RED : Color(0xFF0000)
|
||||||
GREEN : Color(0x00FF00)
|
GREEN : Color(0x00FF00)
|
||||||
@@ -18,6 +24,7 @@ enum class Color(val rgb : Int) {
|
|||||||
fun foo(d: Direction) = when(d) { //no 'else' should be requested
|
fun foo(d: Direction) = when(d) { //no 'else' should be requested
|
||||||
Direction.NORTH -> 1
|
Direction.NORTH -> 1
|
||||||
Direction.SOUTH -> 2
|
Direction.SOUTH -> 2
|
||||||
|
<!INCOMPATIBLE_TYPES!>A<!> -> 1
|
||||||
Direction.WEST -> 3
|
Direction.WEST -> 3
|
||||||
Direction.EAST -> 4
|
Direction.EAST -> 4
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user