unwrap parentheses around range expressions in pattern matching conditions (KT-1742) (thanks to Sergey Mashkov for the suggested fix)
This commit is contained in:
@@ -2868,6 +2868,9 @@ If finally block is present, its last expression is the value of try expression.
|
||||
if (condition instanceof JetWhenConditionInRange) {
|
||||
JetWhenConditionInRange conditionInRange = (JetWhenConditionInRange) condition;
|
||||
JetExpression rangeExpression = conditionInRange.getRangeExpression();
|
||||
while (rangeExpression instanceof JetParenthesizedExpression) {
|
||||
rangeExpression = ((JetParenthesizedExpression)rangeExpression).getExpression();
|
||||
}
|
||||
if(isIntRangeExpr(rangeExpression)) {
|
||||
getInIntRange(new StackValue.Local(subjectLocal, subjectType), (JetBinaryExpression) rangeExpression, conditionInRange.getOperationReference().getReferencedNameElementType() == JetTokens.NOT_IN);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fun box(): String {
|
||||
val x = 2
|
||||
return when(x) {
|
||||
in (1..3) -> "OK"
|
||||
else -> "fail"
|
||||
}
|
||||
}
|
||||
@@ -341,4 +341,9 @@ public class ControlStructuresTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt1899.kt");
|
||||
}
|
||||
|
||||
public void testKt1742() throws Exception {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||
blackBoxFile("regressions/kt1742.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user