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 {
|
fun box(): String {
|
||||||
var x = 1
|
var x = 1
|
||||||
(foo@ x)++
|
(foo@ x)++
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
|
||||||
// IGNORE_BACKEND: JS
|
|
||||||
|
|
||||||
var holder = ""
|
var holder = ""
|
||||||
var globalA: A = A(-1)
|
var globalA: A = A(-1)
|
||||||
get(): A {
|
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
|
package name
|
||||||
|
|
||||||
class Test() {
|
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);
|
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")
|
@TestMetadata("assignmentOperations.kt")
|
||||||
public void testAssignmentOperations() throws Exception {
|
public void testAssignmentOperations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
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);
|
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")
|
@TestMetadata("assignmentOperations.kt")
|
||||||
public void testAssignmentOperations() throws Exception {
|
public void testAssignmentOperations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
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);
|
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")
|
@TestMetadata("assignmentOperations.kt")
|
||||||
public void testAssignmentOperations() throws Exception {
|
public void testAssignmentOperations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
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")
|
@TestMetadata("incWithLabel.kt")
|
||||||
public void testIncWithLabel() throws Exception {
|
public void testIncWithLabel() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/incWithLabel.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/intrinsics/incWithLabel.kt");
|
||||||
try {
|
doTest(fileName);
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
catch (Throwable ignore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt10131.kt")
|
@TestMetadata("kt10131.kt")
|
||||||
@@ -10842,13 +10836,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
@TestMetadata("increment.kt")
|
@TestMetadata("increment.kt")
|
||||||
public void testIncrement() throws Exception {
|
public void testIncrement() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/lazyCodegen/increment.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/lazyCodegen/increment.kt");
|
||||||
try {
|
doTest(fileName);
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
catch (Throwable ignore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("safeAssign.kt")
|
@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);
|
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")
|
@TestMetadata("assignmentOperations.kt")
|
||||||
public void testAssignmentOperations() throws Exception {
|
public void testAssignmentOperations() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/assignmentOperations.kt");
|
||||||
@@ -13641,13 +13635,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
@TestMetadata("kt613.kt")
|
@TestMetadata("kt613.kt")
|
||||||
public void testKt613() throws Exception {
|
public void testKt613() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/kt613.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/kt613.kt");
|
||||||
try {
|
doTest(fileName);
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
catch (Throwable ignore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("kt8928.kt")
|
@TestMetadata("kt8928.kt")
|
||||||
|
|||||||
+4
-6
@@ -30,16 +30,15 @@ public final class AccessTranslationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression,
|
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression, @NotNull TranslationContext context) {
|
||||||
@NotNull TranslationContext context) {
|
|
||||||
return getAccessTranslator(referenceExpression, context, false);
|
return getAccessTranslator(referenceExpression, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression,
|
public static AccessTranslator getAccessTranslator(@NotNull KtExpression referenceExpression,
|
||||||
@NotNull TranslationContext context, boolean forceOrderOfEvaluation) {
|
@NotNull TranslationContext context, boolean forceOrderOfEvaluation) {
|
||||||
assert ((referenceExpression instanceof KtReferenceExpression) ||
|
referenceExpression = KtPsiUtil.deparenthesize(referenceExpression);
|
||||||
(referenceExpression instanceof KtQualifiedExpression));
|
assert referenceExpression != null;
|
||||||
if (referenceExpression instanceof KtQualifiedExpression) {
|
if (referenceExpression instanceof KtQualifiedExpression) {
|
||||||
return QualifiedExpressionTranslator.getAccessTranslator((KtQualifiedExpression) referenceExpression, context, forceOrderOfEvaluation);
|
return QualifiedExpressionTranslator.getAccessTranslator((KtQualifiedExpression) referenceExpression, context, forceOrderOfEvaluation);
|
||||||
}
|
}
|
||||||
@@ -75,8 +74,7 @@ public final class AccessTranslationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JsExpression translateAsGet(@NotNull KtExpression expression,
|
public static JsExpression translateAsGet(@NotNull KtExpression expression, @NotNull TranslationContext context) {
|
||||||
@NotNull TranslationContext context) {
|
|
||||||
return (getAccessTranslator(expression, context)).translateAsGet();
|
return (getAccessTranslator(expression, context)).translateAsGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user