File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
js.tests/test/org/jetbrains/kotlin/js/test/semantics
src/org/jetbrains/kotlin/js/translate/operation
testData/box/expression/evaluationOrder Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -2005,6 +2005,12 @@ public void testAndAndWithSideEffect() throws Exception {
2005
2005
doTest (fileName );
2006
2006
}
2007
2007
2008
+ @ TestMetadata ("andAndWithTmpVarRhs.kt" )
2009
+ public void testAndAndWithTmpVarRhs () throws Exception {
2010
+ String fileName = KotlinTestUtils .navigationMetadata ("js/js.translator/testData/box/expression/evaluationOrder/andAndWithTmpVarRhs.kt" );
2011
+ doTest (fileName );
2012
+ }
2013
+
2008
2014
@ TestMetadata ("assignToArrayElementWithSideEffect.kt" )
2009
2015
public void testAssignToArrayElementWithSideEffect () throws Exception {
2010
2016
String fileName = KotlinTestUtils .navigationMetadata ("js/js.translator/testData/box/expression/evaluationOrder/assignToArrayElementWithSideEffect.kt" );
Original file line number Diff line number Diff line change 21
21
import org .jetbrains .kotlin .descriptors .CallableDescriptor ;
22
22
import org .jetbrains .kotlin .descriptors .FunctionDescriptor ;
23
23
import org .jetbrains .kotlin .js .backend .ast .*;
24
+ import org .jetbrains .kotlin .js .backend .ast .metadata .MetadataProperties ;
24
25
import org .jetbrains .kotlin .js .translate .callTranslator .CallTranslator ;
25
26
import org .jetbrains .kotlin .js .translate .context .TranslationContext ;
26
27
import org .jetbrains .kotlin .js .translate .general .AbstractTranslator ;
@@ -202,10 +203,12 @@ else if (OperatorConventions.IDENTITY_EQUALS_OPERATIONS.contains(operationToken)
202
203
if (rightExpression instanceof JsNameRef ) {
203
204
result = rightExpression ; // Reuse tmp variable
204
205
} else {
205
- result = context ().defineTemporary (rightExpression );
206
+ result = context ().declareTemporary (null ).reference ();
207
+ rightBlock .getStatements ().add (JsAstUtils .asSyntheticStatement (JsAstUtils .assignment (result , rightExpression )));
206
208
}
207
- JsStatement assignmentStatement = JsAstUtils .assignment (result , literalResult ). makeStmt ( );
209
+ JsStatement assignmentStatement = JsAstUtils .asSyntheticStatement ( JsAstUtils . assignment (result , literalResult ));
208
210
ifStatement = JsAstUtils .newJsIf (leftExpression , rightBlock , assignmentStatement );
211
+ MetadataProperties .setSynthetic (ifStatement , true );
209
212
}
210
213
else {
211
214
ifStatement = JsAstUtils .newJsIf (leftExpression , rightBlock );
Original file line number Diff line number Diff line change
1
+ fun foo (arg : Any ): Boolean {
2
+ return arg == " x"
3
+ }
4
+
5
+ fun box (): String {
6
+ val values = listOf (null , " x" )
7
+ return if (values[0 ] == null && foo(values[1 ]!! )) " OK" else " fail"
8
+ }
You can’t perform that action at this time.
0 commit comments