This commit is contained in:
Pavel V. Talanov
2012-11-21 20:50:55 +04:00
parent 10cedf8576
commit a7536e1ae9
2 changed files with 12 additions and 1 deletions
@@ -96,8 +96,12 @@ public final class WhenChecker {
) {
JetSimpleNameExpression reference = getReference(whenExpression.getExpression());
if (reference == null) return false;
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);
return classDescriptor == enumEntry;
}
@@ -9,6 +9,12 @@ enum class Direction {
EAST
}
class A {
class object {
}
}
enum class Color(val rgb : Int) {
RED : Color(0xFF0000)
GREEN : Color(0x00FF00)
@@ -18,6 +24,7 @@ enum class Color(val rgb : Int) {
fun foo(d: Direction) = when(d) { //no 'else' should be requested
Direction.NORTH -> 1
Direction.SOUTH -> 2
<!INCOMPATIBLE_TYPES!>A<!> -> 1
Direction.WEST -> 3
Direction.EAST -> 4
}