JS: deparenthesize LHS of assignment before choosing appropriate AccessTranslator. Fix KT-15169
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
var x = 1
|
||||
(foo@ x)++
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
var holder = ""
|
||||
var globalA: A = A(-1)
|
||||
get(): A {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
annotation class Annotation
|
||||
|
||||
fun box(): String {
|
||||
var v = 0
|
||||
@Annotation v += 1 + 2
|
||||
if (v != 3) return "fail1"
|
||||
|
||||
@Annotation v = 4
|
||||
if (v != 4) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
package name
|
||||
|
||||
class Test() {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public final class AnnotatedAssignmentKt {
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target
|
||||
@java.lang.annotation.Retention
|
||||
@java.lang.annotation.Target
|
||||
public annotation class Annotation
|
||||
+6
@@ -10487,6 +10487,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedAssignment.kt")
|
||||
public void testAnnotatedAssignment() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/annotatedAssignment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentOperations.kt")
|
||||
public void testAssignmentOperations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
||||
|
||||
@@ -10487,6 +10487,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedAssignment.kt")
|
||||
public void testAnnotatedAssignment() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/annotatedAssignment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentOperations.kt")
|
||||
public void testAssignmentOperations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
||||
|
||||
@@ -10487,6 +10487,12 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedAssignment.kt")
|
||||
public void testAnnotatedAssignment() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/annotatedAssignment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentOperations.kt")
|
||||
public void testAssignmentOperations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
||||
|
||||
+9
-21
@@ -9612,13 +9612,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
@TestMetadata("incWithLabel.kt")
|
||||
public void testIncWithLabel() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/incWithLabel.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt10131.kt")
|
||||
@@ -10842,13 +10836,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
@TestMetadata("increment.kt")
|
||||
public void testIncrement() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/lazyCodegen/increment.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("safeAssign.kt")
|
||||
@@ -12354,6 +12342,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotatedAssignment.kt")
|
||||
public void testAnnotatedAssignment() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/annotatedAssignment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentOperations.kt")
|
||||
public void testAssignmentOperations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
||||
@@ -13641,13 +13635,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
@TestMetadata("kt613.kt")
|
||||
public void testKt613() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/kt613.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt8928.kt")
|
||||
|
||||
+4
-6
@@ -30,16 +30,15 @@ public final class AccessTranslationUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression,
|
||||
@NotNull TranslationContext context) {
|
||||
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression, @NotNull TranslationContext context) {
|
||||
return getAccessTranslator(referenceExpression, context, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression,
|
||||
@NotNull TranslationContext context, boolean forceOrderOfEvaluation) {
|
||||
assert ((referenceExpression instanceof KtReferenceExpression) ||
|
||||
(referenceExpression instanceof KtQualifiedExpression));
|
||||
referenceExpression = KtPsiUtil.deparenthesize(referenceExpression);
|
||||
assert referenceExpression != null;
|
||||
if (referenceExpression instanceof KtQualifiedExpression) {
|
||||
return QualifiedExpressionTranslator.getAccessTranslator((KtQualifiedExpression) referenceExpression, context, forceOrderOfEvaluation);
|
||||
}
|
||||
@@ -75,8 +74,7 @@ public final class AccessTranslationUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JsExpression translateAsGet(@NotNull KtExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
public static JsExpression translateAsGet(@NotNull KtExpression expression, @NotNull TranslationContext context) {
|
||||
return (getAccessTranslator(expression, context)).translateAsGet();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user