Support MutablePropertyReferenceN supertypes in LambdaInfo
#KT-37087 Fixed
This commit is contained in:
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.*
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
@@ -60,7 +60,7 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
|
||||
open val hasDispatchReceiver = true
|
||||
|
||||
fun addAllParameters(remapper: FieldRemapper): Parameters {
|
||||
val builder = ParametersBuilder.initializeBuilderFrom(AsmTypes.OBJECT_TYPE, invokeMethod.descriptor, this)
|
||||
val builder = ParametersBuilder.initializeBuilderFrom(OBJECT_TYPE, invokeMethod.descriptor, this)
|
||||
|
||||
for (info in capturedVars) {
|
||||
val field = remapper.findField(FieldInsnNode(0, info.containingLambdaName, info.fieldName, ""))
|
||||
@@ -140,8 +140,8 @@ abstract class DefaultLambda(
|
||||
superName: String?,
|
||||
interfaces: Array<out String>?
|
||||
) {
|
||||
isPropertyReference = superName?.startsWith("kotlin/jvm/internal/PropertyReference") ?: false
|
||||
isFunctionReference = "kotlin/jvm/internal/FunctionReference" == superName
|
||||
isPropertyReference = superName in PROPERTY_REFERENCE_SUPER_CLASSES
|
||||
isFunctionReference = superName == FUNCTION_REFERENCE.internalName
|
||||
|
||||
super.visit(version, access, name, signature, superName, interfaces)
|
||||
}
|
||||
@@ -202,6 +202,13 @@ abstract class DefaultLambda(
|
||||
}
|
||||
|
||||
protected abstract fun mapAsmSignature(sourceCompiler: SourceCompilerForInline): Method
|
||||
|
||||
private companion object {
|
||||
val PROPERTY_REFERENCE_SUPER_CLASSES = listOf(
|
||||
PROPERTY_REFERENCE0, PROPERTY_REFERENCE1, PROPERTY_REFERENCE2,
|
||||
MUTABLE_PROPERTY_REFERENCE0, MUTABLE_PROPERTY_REFERENCE1, MUTABLE_PROPERTY_REFERENCE2
|
||||
).mapTo(HashSet(), Type::getInternalName)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Type.boxReceiverForBoundReference() =
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
class A {
|
||||
var ok: String
|
||||
get() = "OK"
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
inline fun inlineFun(lambda: () -> String = A()::ok): String {
|
||||
return lambda()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return inlineFun()
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
class A {
|
||||
var ok: String
|
||||
get() = "OK"
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
inline fun inlineFun(a: A, lambda: (A) -> String = A::ok): String {
|
||||
return lambda(a)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return inlineFun(A())
|
||||
}
|
||||
+10
@@ -1556,6 +1556,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/innerClassConstuctorReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableBoundPropertyReferenceFromClass.kt")
|
||||
public void testMutableBoundPropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutableBoundPropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutablePropertyReferenceFromClass.kt")
|
||||
public void testMutablePropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutablePropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateFunctionReference.kt")
|
||||
public void testPrivateFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/privateFunctionReference.kt");
|
||||
|
||||
Generated
+10
@@ -1556,6 +1556,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/innerClassConstuctorReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableBoundPropertyReferenceFromClass.kt")
|
||||
public void testMutableBoundPropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutableBoundPropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutablePropertyReferenceFromClass.kt")
|
||||
public void testMutablePropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutablePropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateFunctionReference.kt")
|
||||
public void testPrivateFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/privateFunctionReference.kt");
|
||||
|
||||
+10
@@ -1556,6 +1556,16 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/innerClassConstuctorReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableBoundPropertyReferenceFromClass.kt")
|
||||
public void testMutableBoundPropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutableBoundPropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutablePropertyReferenceFromClass.kt")
|
||||
public void testMutablePropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutablePropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateFunctionReference.kt")
|
||||
public void testPrivateFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/privateFunctionReference.kt");
|
||||
|
||||
Generated
+10
@@ -1556,6 +1556,16 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/innerClassConstuctorReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableBoundPropertyReferenceFromClass.kt")
|
||||
public void testMutableBoundPropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutableBoundPropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutablePropertyReferenceFromClass.kt")
|
||||
public void testMutablePropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutablePropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateFunctionReference.kt")
|
||||
public void testPrivateFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/privateFunctionReference.kt");
|
||||
|
||||
Generated
+10
@@ -373,6 +373,16 @@ public class IrInlineDefaultValuesTestsGenerated extends AbstractIrInlineDefault
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/innerClassConstuctorReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableBoundPropertyReferenceFromClass.kt")
|
||||
public void testMutableBoundPropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutableBoundPropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutablePropertyReferenceFromClass.kt")
|
||||
public void testMutablePropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutablePropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateFunctionReference.kt")
|
||||
public void testPrivateFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/privateFunctionReference.kt");
|
||||
|
||||
Generated
+10
@@ -373,6 +373,16 @@ public class InlineDefaultValuesTestsGenerated extends AbstractInlineDefaultValu
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/innerClassConstuctorReference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableBoundPropertyReferenceFromClass.kt")
|
||||
public void testMutableBoundPropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutableBoundPropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutablePropertyReferenceFromClass.kt")
|
||||
public void testMutablePropertyReferenceFromClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/mutablePropertyReferenceFromClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateFunctionReference.kt")
|
||||
public void testPrivateFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences/privateFunctionReference.kt");
|
||||
|
||||
Reference in New Issue
Block a user