Support 'when' with subject variable in JVM BE
This commit is contained in:
@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
|||||||
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
|
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
|
||||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
|
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
|
||||||
import org.jetbrains.kotlin.codegen.context.*;
|
import org.jetbrains.kotlin.codegen.context.*;
|
||||||
import org.jetbrains.kotlin.codegen.coroutines.*;
|
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenForLambda;
|
||||||
|
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
|
||||||
|
import org.jetbrains.kotlin.codegen.coroutines.ResolvedCallWithRealDescriptor;
|
||||||
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension;
|
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension;
|
||||||
import org.jetbrains.kotlin.codegen.inline.*;
|
import org.jetbrains.kotlin.codegen.inline.*;
|
||||||
import org.jetbrains.kotlin.codegen.intrinsics.*;
|
import org.jetbrains.kotlin.codegen.intrinsics.*;
|
||||||
@@ -3140,10 +3142,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
@Nullable KtExpression left,
|
@Nullable KtExpression left,
|
||||||
@Nullable KtExpression right,
|
@Nullable KtExpression right,
|
||||||
@NotNull IElementType opToken,
|
@NotNull IElementType opToken,
|
||||||
@Nullable StackValue pregeneratedLeft,
|
@Nullable StackValue pregeneratedSubject,
|
||||||
@Nullable PrimitiveNumericComparisonInfo primitiveNumericComparisonInfo
|
@Nullable PrimitiveNumericComparisonInfo primitiveNumericComparisonInfo
|
||||||
) {
|
) {
|
||||||
Type leftType = expressionType(left);
|
Type leftType = pregeneratedSubject != null ? pregeneratedSubject.type : expressionType(left);
|
||||||
Type rightType = expressionType(right);
|
Type rightType = expressionType(right);
|
||||||
|
|
||||||
if (KtPsiUtil.isNullConstant(left)) {
|
if (KtPsiUtil.isNullConstant(left)) {
|
||||||
@@ -3151,7 +3153,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (KtPsiUtil.isNullConstant(right)) {
|
if (KtPsiUtil.isNullConstant(right)) {
|
||||||
return genCmpWithNull(left, opToken, pregeneratedLeft);
|
return genCmpWithNull(left, opToken, pregeneratedSubject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isIntZero(left, leftType) && isIntPrimitive(rightType)) {
|
if (isIntZero(left, leftType) && isIntPrimitive(rightType)) {
|
||||||
@@ -3159,23 +3161,23 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isIntZero(right, rightType) && isIntPrimitive(leftType)) {
|
if (isIntZero(right, rightType) && isIntPrimitive(leftType)) {
|
||||||
return genCmpWithZero(left, opToken, pregeneratedLeft);
|
return genCmpWithZero(left, opToken, pregeneratedSubject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pregeneratedLeft == null && left instanceof KtSafeQualifiedExpression &&
|
if (pregeneratedSubject == null && left instanceof KtSafeQualifiedExpression &&
|
||||||
isSelectorPureNonNullType((KtSafeQualifiedExpression) left) && isPrimitive(rightType)) {
|
isSelectorPureNonNullType((KtSafeQualifiedExpression) left) && isPrimitive(rightType)) {
|
||||||
return genCmpSafeCallToPrimitive((KtSafeQualifiedExpression) left, right, rightType, opToken);
|
return genCmpSafeCallToPrimitive((KtSafeQualifiedExpression) left, right, rightType, opToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPrimitive(leftType) && right instanceof KtSafeQualifiedExpression &&
|
if (isPrimitive(leftType) && right instanceof KtSafeQualifiedExpression &&
|
||||||
isSelectorPureNonNullType(((KtSafeQualifiedExpression) right))) {
|
isSelectorPureNonNullType(((KtSafeQualifiedExpression) right))) {
|
||||||
return genCmpPrimitiveToSafeCall(left, leftType, (KtSafeQualifiedExpression) right, opToken, pregeneratedLeft);
|
return genCmpPrimitiveToSafeCall(left, leftType, (KtSafeQualifiedExpression) right, opToken, pregeneratedSubject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BoxedToPrimitiveEquality.isApplicable(opToken, leftType, rightType)) {
|
if (BoxedToPrimitiveEquality.isApplicable(opToken, leftType, rightType)) {
|
||||||
return BoxedToPrimitiveEquality.create(
|
return BoxedToPrimitiveEquality.create(
|
||||||
opToken,
|
opToken,
|
||||||
genLazyUnlessProvided(pregeneratedLeft, left, leftType), leftType,
|
genLazyUnlessProvided(pregeneratedSubject, left, leftType), leftType,
|
||||||
genLazy(right, rightType), rightType,
|
genLazy(right, rightType), rightType,
|
||||||
myFrameMap
|
myFrameMap
|
||||||
);
|
);
|
||||||
@@ -3184,7 +3186,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
if (PrimitiveToBoxedEquality.isApplicable(opToken, leftType, rightType)) {
|
if (PrimitiveToBoxedEquality.isApplicable(opToken, leftType, rightType)) {
|
||||||
return PrimitiveToBoxedEquality.create(
|
return PrimitiveToBoxedEquality.create(
|
||||||
opToken,
|
opToken,
|
||||||
genLazyUnlessProvided(pregeneratedLeft, left, leftType), leftType,
|
genLazyUnlessProvided(pregeneratedSubject, left, leftType), leftType,
|
||||||
genLazy(right, rightType), rightType
|
genLazy(right, rightType), rightType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3192,7 +3194,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
if (PrimitiveToObjectEquality.isApplicable(opToken, leftType, rightType)) {
|
if (PrimitiveToObjectEquality.isApplicable(opToken, leftType, rightType)) {
|
||||||
return PrimitiveToObjectEquality.create(
|
return PrimitiveToObjectEquality.create(
|
||||||
opToken,
|
opToken,
|
||||||
genLazyUnlessProvided(pregeneratedLeft, left, leftType), leftType,
|
genLazyUnlessProvided(pregeneratedSubject, left, leftType), leftType,
|
||||||
genLazy(right, rightType), rightType
|
genLazy(right, rightType), rightType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3209,28 +3211,34 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
return StackValue.cmp(
|
return StackValue.cmp(
|
||||||
opToken,
|
opToken,
|
||||||
operandType,
|
operandType,
|
||||||
genLazyUnlessProvided(pregeneratedLeft, left, leftType),
|
genLazyUnlessProvided(pregeneratedSubject, left, leftType),
|
||||||
genLazy(right, rightType)
|
genLazy(right, rightType)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
|
if ((opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) &&
|
||||||
(isEnumClass(bindingContext.getType(left).getConstructor().getDeclarationDescriptor()) ||
|
(isEnumExpression(left) || isEnumExpression(right))) {
|
||||||
isEnumClass(bindingContext.getType(right).getConstructor().getDeclarationDescriptor()))) {
|
|
||||||
// Reference equality can be used for enums.
|
// Reference equality can be used for enums.
|
||||||
return StackValue.cmp(
|
return StackValue.cmp(
|
||||||
opToken == KtTokens.EQEQ ? KtTokens.EQEQEQ : KtTokens.EXCLEQEQEQ,
|
opToken == KtTokens.EQEQ ? KtTokens.EQEQEQ : KtTokens.EXCLEQEQEQ,
|
||||||
OBJECT_TYPE,
|
OBJECT_TYPE,
|
||||||
genLazyUnlessProvided(pregeneratedLeft, left, leftType),
|
genLazyUnlessProvided(pregeneratedSubject, left, leftType),
|
||||||
genLazy(right, rightType)
|
genLazy(right, rightType)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return genEqualsForExpressionsPreferIeee754Arithmetic(
|
return genEqualsForExpressionsPreferIeee754Arithmetic(
|
||||||
left, right, opToken, leftType, rightType, pregeneratedLeft, primitiveNumericComparisonInfo
|
left, right, opToken, leftType, rightType, pregeneratedSubject, primitiveNumericComparisonInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEnumExpression(@Nullable KtExpression expression) {
|
||||||
|
KotlinType expressionType = bindingContext.getType(expression);
|
||||||
|
if (expressionType == null) return false;
|
||||||
|
return isEnumClass(expressionType.getConstructor().getDeclarationDescriptor());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isSelectorPureNonNullType(@NotNull KtSafeQualifiedExpression safeExpression) {
|
private boolean isSelectorPureNonNullType(@NotNull KtSafeQualifiedExpression safeExpression) {
|
||||||
KtExpression expression = safeExpression.getSelectorExpression();
|
KtExpression expression = safeExpression.getSelectorExpression();
|
||||||
if (expression == null) return false;
|
if (expression == null) return false;
|
||||||
@@ -4489,12 +4497,12 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StackValue generateWhenExpression(KtWhenExpression expression, boolean isStatement) {
|
public StackValue generateWhenExpression(KtWhenExpression expression, boolean isStatement) {
|
||||||
KtExpression expr = expression.getSubjectExpression();
|
|
||||||
Type subjectType = expressionType(expr);
|
|
||||||
|
|
||||||
Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);
|
Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);
|
||||||
|
|
||||||
return StackValue.operation(resultType, v -> {
|
return StackValue.operation(resultType, v -> {
|
||||||
|
KtProperty subjectVariable = expression.getSubjectVariable();
|
||||||
|
KtExpression subjectExpression = expression.getSubjectExpression();
|
||||||
|
|
||||||
SwitchCodegen switchCodegen = switchCodegenProvider.buildAppropriateSwitchCodegenIfPossible(
|
SwitchCodegen switchCodegen = switchCodegenProvider.buildAppropriateSwitchCodegenIfPossible(
|
||||||
expression, isStatement, CodegenUtil.isExhaustive(bindingContext, expression, isStatement)
|
expression, isStatement, CodegenUtil.isExhaustive(bindingContext, expression, isStatement)
|
||||||
);
|
);
|
||||||
@@ -4503,12 +4511,27 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType) : -1;
|
int subjectLocal;
|
||||||
if (subjectLocal != -1) {
|
Type subjectType;
|
||||||
gen(expr, subjectType);
|
if (subjectVariable != null) {
|
||||||
tempVariables.put(expr, StackValue.local(subjectLocal, subjectType));
|
VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, subjectVariable);
|
||||||
|
assert variableDescriptor != null : "Unresolved subject variable: " + subjectVariable.getName();
|
||||||
|
subjectType = asmType(variableDescriptor.getType());
|
||||||
|
subjectLocal = myFrameMap.enter(variableDescriptor, subjectType);
|
||||||
|
visitProperty(subjectVariable, null);
|
||||||
|
tempVariables.put(subjectExpression, StackValue.local(subjectLocal, subjectType));
|
||||||
|
}
|
||||||
|
else if (subjectExpression != null) {
|
||||||
|
subjectType = expressionType(subjectExpression);
|
||||||
|
subjectLocal = myFrameMap.enterTemp(subjectType);
|
||||||
|
gen(subjectExpression, subjectType);
|
||||||
|
tempVariables.put(subjectExpression, StackValue.local(subjectLocal, subjectType));
|
||||||
v.store(subjectLocal, subjectType);
|
v.store(subjectLocal, subjectType);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
subjectLocal = -1;
|
||||||
|
subjectType = Type.VOID_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
Label end = new Label();
|
Label end = new Label();
|
||||||
boolean hasElse = KtPsiUtil.checkWhenExpressionHasSingleElse(expression);
|
boolean hasElse = KtPsiUtil.checkWhenExpressionHasSingleElse(expression);
|
||||||
@@ -4524,7 +4547,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
if (!whenEntry.isElse()) {
|
if (!whenEntry.isElse()) {
|
||||||
KtWhenCondition[] conditions = whenEntry.getConditions();
|
KtWhenCondition[] conditions = whenEntry.getConditions();
|
||||||
for (int i = 0; i < conditions.length; i++) {
|
for (int i = 0; i < conditions.length; i++) {
|
||||||
StackValue conditionValue = generateWhenCondition(expr, subjectType, subjectLocal, conditions[i]);
|
StackValue conditionValue = generateWhenCondition(subjectExpression, subjectType, subjectLocal, conditions[i]);
|
||||||
BranchedValue.Companion.condJump(conditionValue, nextCondition, true, v);
|
BranchedValue.Companion.condJump(conditionValue, nextCondition, true, v);
|
||||||
if (i < conditions.length - 1) {
|
if (i < conditions.length - 1) {
|
||||||
v.goTo(thisEntry);
|
v.goTo(thisEntry);
|
||||||
@@ -4550,7 +4573,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
v.mark(end);
|
v.mark(end);
|
||||||
|
|
||||||
myFrameMap.leaveTemp(subjectType);
|
myFrameMap.leaveTemp(subjectType);
|
||||||
tempVariables.remove(expr);
|
tempVariables.remove(subjectExpression);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var y: String = "OK"
|
||||||
|
|
||||||
|
var materializer: (() -> String)? = null
|
||||||
|
|
||||||
|
when (val x = y) {
|
||||||
|
"OK" -> materializer = { x }
|
||||||
|
else -> return "x is $x"
|
||||||
|
}
|
||||||
|
|
||||||
|
y = "Fail"
|
||||||
|
|
||||||
|
return materializer!!.invoke()
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
|
||||||
|
val x = 1
|
||||||
|
|
||||||
|
fun box() =
|
||||||
|
when (val y = x) {
|
||||||
|
1 -> "OK"
|
||||||
|
else -> "Fail: $y"
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
|
||||||
|
val x: Any = 1
|
||||||
|
|
||||||
|
fun box() =
|
||||||
|
when (val y = x) {
|
||||||
|
is Int -> "OK"
|
||||||
|
else -> "Fail: $y"
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||||
|
|
||||||
|
val x = 1
|
||||||
|
|
||||||
|
fun box() =
|
||||||
|
when (val y = x) {
|
||||||
|
in 0..2 -> "OK"
|
||||||
|
else -> "Fail: $y"
|
||||||
|
}
|
||||||
Generated
+33
@@ -21650,5 +21650,38 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/when/whenSubjectVariable")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class WhenSubjectVariable extends AbstractIrBlackBoxCodegenTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInWhenSubjectVariable() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/when/whenSubjectVariable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("captureSubjectVariable.kt")
|
||||||
|
public void testCaptureSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/captureSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("equalityWithSubjectVariable.kt")
|
||||||
|
public void testEqualityWithSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/equalityWithSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("isCheckOnSubjectVariable.kt")
|
||||||
|
public void testIsCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/isCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rangeCheckOnSubjectVariable.kt")
|
||||||
|
public void testRangeCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/rangeCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
@@ -21650,5 +21650,38 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/when/whenSubjectVariable")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class WhenSubjectVariable extends AbstractBlackBoxCodegenTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInWhenSubjectVariable() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/when/whenSubjectVariable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("captureSubjectVariable.kt")
|
||||||
|
public void testCaptureSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/captureSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("equalityWithSubjectVariable.kt")
|
||||||
|
public void testEqualityWithSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/equalityWithSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("isCheckOnSubjectVariable.kt")
|
||||||
|
public void testIsCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/isCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rangeCheckOnSubjectVariable.kt")
|
||||||
|
public void testRangeCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/rangeCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
@@ -21650,5 +21650,38 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/when/whenSubjectVariable")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class WhenSubjectVariable extends AbstractLightAnalysisModeTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInWhenSubjectVariable() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/when/whenSubjectVariable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("captureSubjectVariable.kt")
|
||||||
|
public void testCaptureSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/captureSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("equalityWithSubjectVariable.kt")
|
||||||
|
public void testEqualityWithSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/equalityWithSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("isCheckOnSubjectVariable.kt")
|
||||||
|
public void testIsCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/isCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rangeCheckOnSubjectVariable.kt")
|
||||||
|
public void testRangeCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/rangeCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
@@ -19543,5 +19543,38 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
runTest("compiler/testData/codegen/box/when/stringOptimization/statement.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/when/whenSubjectVariable")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class WhenSubjectVariable extends AbstractJsCodegenBoxTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInWhenSubjectVariable() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/when/whenSubjectVariable"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("captureSubjectVariable.kt")
|
||||||
|
public void testCaptureSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/captureSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("equalityWithSubjectVariable.kt")
|
||||||
|
public void testEqualityWithSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/equalityWithSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("isCheckOnSubjectVariable.kt")
|
||||||
|
public void testIsCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/isCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("rangeCheckOnSubjectVariable.kt")
|
||||||
|
public void testRangeCheckOnSubjectVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/whenSubjectVariable/rangeCheckOnSubjectVariable.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user