[FIR] Insert fake source for FIR for array access temporaries
This commit is contained in:
committed by
Ilya Kirillov
parent
46feb00ee7
commit
fcabc60471
+8
@@ -0,0 +1,8 @@
|
|||||||
|
interface MyMap<K, V> {
|
||||||
|
operator fun get(k: K): V
|
||||||
|
operator fun set(k: K, v: V)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(m: MyMap<String, Int>) {
|
||||||
|
<expr>m</expr>["a"] += 1
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|<local>/m|
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
operator fun inc(): A
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MyMap<K, V> {
|
||||||
|
operator fun get(k: K): V
|
||||||
|
operator fun set(k: K, v: V): Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(m: MyMap<String, A>) {
|
||||||
|
<expr>m["a"]++</expr>
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtPostfixExpression
|
||||||
|
FIR element: FirFunctionCallImpl
|
||||||
|
FIR source kind: DesugaredIncrementOrDecrement
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|<local>/<array>|.R|SubstitutionOverride</MyMap.set: R|kotlin/Unit|>|(R|<local>/<index_0>|, R|<local>/<unary>|.R|/A.inc|())
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
operator fun inc(): A
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MyMap<K, V> {
|
||||||
|
operator fun get(k: K): V
|
||||||
|
operator fun set(k: K, v: V): Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(m: MyMap<String, A>) {
|
||||||
|
<expr>m</expr>["a"]++
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|<local>/m|
|
||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
interface A {
|
||||||
|
operator fun inc(): A
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MyMap<K, V> {
|
||||||
|
operator fun get(k: K): V
|
||||||
|
operator fun set(k: K, v: V): Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(m: MyMap<String, A>) {
|
||||||
|
<expr>m["a"]</expr>++
|
||||||
|
}
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtArrayAccessExpression
|
||||||
|
FIR element: FirResolvedNamedReferenceImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|SubstitutionOverride</MyMap.set: R|kotlin/Unit|>|
|
||||||
+24
@@ -133,6 +133,12 @@ public class GetOrBuildFirTestGenerated extends AbstractGetOrBuildFirTest {
|
|||||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/compoundAssignWithArrayAccessConvention_lhs.kt");
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/compoundAssignWithArrayAccessConvention_lhs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("compoundAssignWithArrayAccessConvention_propertyAccess.kt")
|
||||||
|
public void testCompoundAssignWithArrayAccessConvention_propertyAccess() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/compoundAssignWithArrayAccessConvention_propertyAccess.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("compoundAssignWithArrayGetConvention.kt")
|
@TestMetadata("compoundAssignWithArrayGetConvention.kt")
|
||||||
public void testCompoundAssignWithArrayGetConvention() throws Exception {
|
public void testCompoundAssignWithArrayGetConvention() throws Exception {
|
||||||
@@ -163,6 +169,24 @@ public class GetOrBuildFirTestGenerated extends AbstractGetOrBuildFirTest {
|
|||||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/functionCallArgumentList.kt");
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/functionCallArgumentList.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incWithArrayAccessConvention.kt")
|
||||||
|
public void testIncWithArrayAccessConvention() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/incWithArrayAccessConvention.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incWithArrayAccessConvention_propertyAccess.kt")
|
||||||
|
public void testIncWithArrayAccessConvention_propertyAccess() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/incWithArrayAccessConvention_propertyAccess.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incWithArrayAccessConvention_set.kt")
|
||||||
|
public void testIncWithArrayAccessConvention_set() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/incWithArrayAccessConvention_set.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("invokeCallArgumentList.kt")
|
@TestMetadata("invokeCallArgumentList.kt")
|
||||||
public void testInvokeCallArgumentList() throws Exception {
|
public void testInvokeCallArgumentList() throws Exception {
|
||||||
|
|||||||
+1
@@ -13,6 +13,7 @@ fun String.walkTopDown(f: (File) -> Unit) {
|
|||||||
if (file.isDirectory) continue
|
if (file.isDirectory) continue
|
||||||
if (file.path.contains("kotlin-native") ||
|
if (file.path.contains("kotlin-native") ||
|
||||||
file.path.contains("testData") ||
|
file.path.contains("testData") ||
|
||||||
|
file.path.contains("testdata") ||
|
||||||
file.path.contains("resources")) continue
|
file.path.contains("resources")) continue
|
||||||
if (file.extension != "kt") continue
|
if (file.extension != "kt") continue
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -802,7 +802,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
|||||||
|
|
||||||
val arrayVariable = generateTemporaryVariable(
|
val arrayVariable = generateTemporaryVariable(
|
||||||
baseModuleData,
|
baseModuleData,
|
||||||
array?.toFirSourceElement(),
|
array?.toFirSourceElement(KtFakeSourceElementKind.ArrayAccessNameReference),
|
||||||
name = SpecialNames.ARRAY,
|
name = SpecialNames.ARRAY,
|
||||||
initializer = arrayReceiver,
|
initializer = arrayReceiver,
|
||||||
).also { statements += it }
|
).also { statements += it }
|
||||||
|
|||||||
Reference in New Issue
Block a user