diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 78328703c3f..0c902024264 100644 --- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1871,6 +1871,16 @@ public class ExpressionCodegen extends JetVisitor { invokeMethodWithArguments(callableMethod, (JetCallExpression) call, true); conditionValue = StackValue.onStack(Type.BOOLEAN_TYPE); } + else if (call instanceof JetSimpleNameExpression) { + final DeclarationDescriptor descriptor = bindingContext.resolveReferenceExpression((JetSimpleNameExpression) call); + if (descriptor instanceof PropertyDescriptor) { + v.load(subjectLocal, subjectType); + conditionValue = intermediateValueForProperty((PropertyDescriptor) descriptor, false, false); + } + else { + throw new UnsupportedOperationException("unknown simple name resolve result: " + descriptor); + } + } else { throw new UnsupportedOperationException("unsupported kind of call suffix"); } diff --git a/idea/testData/codegen/patternMatching/callProperty.jet b/idea/testData/codegen/patternMatching/callProperty.jet new file mode 100644 index 00000000000..b52ac44de96 --- /dev/null +++ b/idea/testData/codegen/patternMatching/callProperty.jet @@ -0,0 +1,9 @@ +class C(val p: Boolean) { } + +fun box(): String { + val c = C(true) + return when(c) { + .p => "OK" + else => "fail" + } +} diff --git a/idea/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java b/idea/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java index d2dc3efd9eb..6bc4d686f52 100644 --- a/idea/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java @@ -77,6 +77,10 @@ public class PatternMatchingTest extends CodegenTestCase { assertEquals("something", foo.invoke(null, "C#")); } + public void testCallProperty() throws Exception { + blackBoxFile("patternMatching/callProperty.jet"); + } + public void testNames() throws Exception { loadText("fun foo(x: (Any, Any)) = when(x) { is (val a is String, *) => a; else => \"something\" }"); Method foo = generateFunction();