Fix isNegated psi method in KtWhenConditionInRange

^KT-34395 Fixed
This commit is contained in:
victor.petukhov
2020-01-10 14:52:45 +03:00
committed by Victor Petukhov
parent a10f37dd50
commit fc7b836151
5 changed files with 6 additions and 8 deletions
@@ -611,8 +611,8 @@ class ExpressionsConverter(
var isNegate = false
var firExpression: FirExpression = FirErrorExpressionImpl(null, FirSimpleDiagnostic("No range in condition with range", DiagnosticKind.Syntax))
whenCondition.forEachChildren {
when (it.tokenType) {
NOT_IN -> isNegate = true
when {
it.tokenType == OPERATION_REFERENCE && it.asText == NOT_IN.value -> isNegate = true
else -> if (it.isExpression()) firExpression = getAsFirExpression(it)
}
}
@@ -29,7 +29,7 @@ public class KtWhenConditionInRange extends KtWhenCondition {
}
public boolean isNegated() {
return getNode().findChildByType(KtTokens.NOT_IN) != null;
return getOperationReference().getNode().findChildByType(KtTokens.NOT_IN) != null;
}
@Nullable @IfNotParsed
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun box(): String {
val shouldBeTrue = 555555555555555555L in 123456789123456789L..987654321987654321L
if (!shouldBeTrue) return "Fail 1"
@@ -29,8 +29,7 @@ FILE fqName:<root> fileName:/whenWithSubjectVariable.kt
GET_VAR 'val y: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
then: CONST Int type=kotlin.Int value=3
BRANCH
if: ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [kotlin/ranges/IntRange.contains]>#' type=IrErrorType
GET_VAR 'val y: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
if: ERROR_CALL 'Unresolved reference: <Unresolved name: not>#' type=IrErrorType
then: CONST Int type=kotlin.Int value=4
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
+2 -2
View File
@@ -11,7 +11,7 @@ Crumbs:
when (xxx)
…num.SomeLongValue ->
when (yyy)
in Int.MIN_VALUE..… ->
!in Int.MIN_VALUE..… ->
when (zzz)
is A,… ->
when (x1)
@@ -31,7 +31,7 @@ Tooltips:
when (xxx)
SomeEnum.SomeLongValue ->
when (yyy)
in Int.MIN_VALUE..Int.MAX_VALUE ->
!in Int.MIN_VALUE..Int.MAX_VALUE ->
when (zzz)
is A,… ->
when (x1)