Don't recognize IrVariable as declaration scope in inlining
#KT-42815 Fixed
This commit is contained in:
committed by
max-kammerer
parent
7f51f57998
commit
c5015c9294
+10
@@ -246,6 +246,16 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
+3
-5
@@ -9,10 +9,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineFunctionCall
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineIrExpression
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationBase
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlock
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCallableReference
|
||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
||||
@@ -25,7 +22,8 @@ internal open class IrInlineReferenceLocator(private val context: JvmBackendCont
|
||||
}
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclarationBase, data: IrDeclaration?) {
|
||||
declaration.acceptChildren(this, declaration)
|
||||
val scope = if (declaration is IrVariable) data else declaration
|
||||
declaration.acceptChildren(this, scope)
|
||||
}
|
||||
|
||||
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: IrDeclaration?) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun myRun(x: () -> String) = x()
|
||||
|
||||
// FILE: 2.kt
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
class C {
|
||||
val x: String
|
||||
init {
|
||||
val y = myRun { { "OK" }() }
|
||||
x = y
|
||||
}
|
||||
|
||||
constructor(y: Int)
|
||||
constructor(y: String)
|
||||
}
|
||||
|
||||
fun box(): String = C("").x
|
||||
@@ -0,0 +1,30 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun myRun( x: () -> String): Lazy<String> {
|
||||
val value2 = x()
|
||||
return object : Lazy<String> {
|
||||
override val value: String
|
||||
get() = value2
|
||||
|
||||
override fun isInitialized(): Boolean = true
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
class C {
|
||||
val x: String
|
||||
init {
|
||||
val y by myRun { { "OK" }() }
|
||||
x = y
|
||||
}
|
||||
|
||||
constructor(y: Int)
|
||||
constructor(y: String)
|
||||
}
|
||||
|
||||
fun box(): String = C("").x
|
||||
+10
@@ -246,6 +246,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Generated
+10
@@ -246,6 +246,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Generated
+10
@@ -246,6 +246,16 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
+10
@@ -246,6 +246,16 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Generated
+10
@@ -246,6 +246,16 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Generated
+10
@@ -246,6 +246,16 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
+10
@@ -226,6 +226,16 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Generated
+10
@@ -226,6 +226,16 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Generated
+10
@@ -226,6 +226,16 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt38197.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815.kt")
|
||||
public void testKt42815() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42815_delegated.kt")
|
||||
public void testKt42815_delegated() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt42815_delegated.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6552.kt")
|
||||
public void testKt6552() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");
|
||||
|
||||
Reference in New Issue
Block a user