Minor: move condition for boxed==primitive to corresponding isApplicable
This commit is contained in:
+12
-11
@@ -217,9 +217,9 @@ class BoxedToPrimitiveEquality private constructor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun create(opToken: IElementType, leftBoxed: StackValue, rightPrimitive: StackValue, primitiveType: Type): BranchedValue =
|
fun create(opToken: IElementType, leftBoxed: StackValue, leftType: Type, rightPrimitive: StackValue, primitiveType: Type): BranchedValue =
|
||||||
if (!isApplicable(opToken, primitiveType))
|
if (!isApplicable(opToken, leftType, primitiveType))
|
||||||
throw IllegalArgumentException("Not applicable for $opToken, $primitiveType")
|
throw IllegalArgumentException("Not applicable for $opToken, $leftType, $primitiveType")
|
||||||
else when (opToken) {
|
else when (opToken) {
|
||||||
KtTokens.EQEQ -> BoxedToPrimitiveEquality(leftBoxed, rightPrimitive, primitiveType)
|
KtTokens.EQEQ -> BoxedToPrimitiveEquality(leftBoxed, rightPrimitive, primitiveType)
|
||||||
KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(leftBoxed, rightPrimitive, primitiveType))
|
KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(leftBoxed, rightPrimitive, primitiveType))
|
||||||
@@ -227,16 +227,17 @@ class BoxedToPrimitiveEquality private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun isApplicable(opToken: IElementType, primitiveType: Type) =
|
fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) =
|
||||||
(opToken == KtTokens.EQEQ ||
|
(opToken == KtTokens.EQEQ ||
|
||||||
opToken == KtTokens.EXCLEQ
|
opToken == KtTokens.EXCLEQ
|
||||||
) &&
|
) &&
|
||||||
(primitiveType == Type.BOOLEAN_TYPE ||
|
(rightType == Type.BOOLEAN_TYPE ||
|
||||||
primitiveType == Type.CHAR_TYPE ||
|
rightType == Type.CHAR_TYPE ||
|
||||||
primitiveType == Type.BYTE_TYPE ||
|
rightType == Type.BYTE_TYPE ||
|
||||||
primitiveType == Type.SHORT_TYPE ||
|
rightType == Type.SHORT_TYPE ||
|
||||||
primitiveType == Type.INT_TYPE ||
|
rightType == Type.INT_TYPE ||
|
||||||
primitiveType == Type.LONG_TYPE
|
rightType == Type.LONG_TYPE
|
||||||
)
|
) &&
|
||||||
|
AsmUtil.isBoxedTypeOf(leftType, rightType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2895,8 +2895,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
return genCmpPrimitiveToSafeCall(left, leftType, (KtSafeQualifiedExpression) right, opToken);
|
return genCmpPrimitiveToSafeCall(left, leftType, (KtSafeQualifiedExpression) right, opToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBoxedTypeOf(leftType, rightType) && BoxedToPrimitiveEquality.isApplicable(opToken, rightType)) {
|
if (BoxedToPrimitiveEquality.isApplicable(opToken, leftType, rightType)) {
|
||||||
return BoxedToPrimitiveEquality.create(opToken, genLazy(left, leftType), genLazy(right, rightType), rightType);
|
return BoxedToPrimitiveEquality.create(opToken, genLazy(left, leftType), leftType, genLazy(right, rightType), rightType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPrimitive(leftType) != isPrimitive(rightType)) {
|
if (isPrimitive(leftType) != isPrimitive(rightType)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user