diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 56275f3e074..15c672656f4 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -2038,6 +2038,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("javaField.kt") public void testJavaField() throws Exception { runTest("compiler/testData/codegen/box/callableReference/javaField.kt"); diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index a1714ba5c82..57d3bf7dd27 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1499,6 +1499,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("genericMember.kt") public void testGenericMember() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/genericMember.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index f955b4e0137..63a4d1bf247 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.ir.* import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi -import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.DescriptorVisibilities +import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.builders.declarations.* @@ -74,7 +74,10 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) override fun visitFunctionReference(expression: IrFunctionReference): IrExpression { expression.transformChildrenVoid(this) - return if (expression.isIgnored) expression else FunctionReferenceBuilder(expression).build() + return if (expression.isIgnored) + expression + else + FunctionReferenceBuilder(expression).build() } // Handle SAM conversions which wrap a function reference: diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index 0d23ea2183c..afb24766516 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.builtins.createFunctionType import org.jetbrains.kotlin.builtins.isKFunctionType import org.jetbrains.kotlin.builtins.isKSuspendFunctionType import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.DescriptorMetadataSource import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction @@ -34,7 +33,9 @@ import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol -import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.ir.util.referenceClassifier +import org.jetbrains.kotlin.ir.util.referenceFunction +import org.jetbrains.kotlin.ir.util.withScope import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -46,7 +47,6 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.expressions.DoubleColonLHS -import org.jetbrains.kotlin.utils.SmartList class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index d2309d11fcf..c70f623de37 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyProperty import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* @@ -1078,18 +1077,37 @@ private fun makeKotlinType( classifier: IrClassifierSymbol, arguments: List, hasQuestionMark: Boolean -): SimpleType = when (classifier) { - is IrTypeParameterSymbol -> classifier.owner.toIrBasedDescriptor().defaultType - is IrClassSymbol -> { - val classDescriptor = classifier.owner.toIrBasedDescriptor() - val kotlinTypeArguments = arguments.mapIndexed { index, it -> - when (it) { - is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toIrBasedKotlinType()) - is IrStarProjection -> StarProjectionImpl(classDescriptor.typeConstructor.parameters[index]) - else -> error(it) +): SimpleType = + when (classifier) { + is IrTypeParameterSymbol -> classifier.owner.toIrBasedDescriptor().defaultType + is IrClassSymbol -> { + val classDescriptor = classifier.owner.toIrBasedDescriptor() + val kotlinTypeArguments = arguments.mapIndexed { index, it -> + when (it) { + is IrTypeProjection -> TypeProjectionImpl(it.variance, it.type.toIrBasedKotlinType()) + is IrStarProjection -> StarProjectionImpl(classDescriptor.typeConstructor.parameters[index]) + else -> error(it) + } + } + + try { + classDescriptor.defaultType.replace(newArguments = kotlinTypeArguments).makeNullableAsSpecified(hasQuestionMark) + } catch (e: Throwable) { + throw RuntimeException( + "Classifier: $classDescriptor\n" + + "Type parameters:\n" + + classDescriptor.defaultType.constructor.parameters.withIndex() + .joinToString(separator = "\n") { + "${it.index}: ${(it.value as IrBasedTypeParameterDescriptor).owner.render()}" + } + + "\nType arguments:\n" + + arguments.withIndex() + .joinToString(separator = "\n") { + "${it.index}: ${it.value.render()}" + }, + e + ) } } - classDescriptor.defaultType.replace(newArguments = kotlinTypeArguments).makeNullableAsSpecified(hasQuestionMark) + else -> error("unknown classifier kind $classifier") } - else -> error("unknown classifier kind $classifier") -} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt index 195dc7b234f..e9dd29d08ac 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt @@ -390,9 +390,9 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon } } -fun extractTypeParameters(klass: IrDeclarationParent): List { +fun extractTypeParameters(parent: IrDeclarationParent): List { val result = mutableListOf() - var current: IrDeclarationParent? = klass + var current: IrDeclarationParent? = parent while (current != null) { (current as? IrTypeParametersContainer)?.let { result += it.typeParameters } current = @@ -404,9 +404,11 @@ fun extractTypeParameters(klass: IrDeclarationParent): List { else -> null } is IrConstructor -> current.parent as IrClass - is IrFunction -> if (current.visibility == DescriptorVisibilities.LOCAL || current.dispatchReceiverParameter != null) { - current.parent - } else null + is IrFunction -> + if (current.visibility == DescriptorVisibilities.LOCAL || current.dispatchReceiverParameter != null) + current.parent + else + null else -> null } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt index f7f14c8288d..148e8ad430b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypes.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.ir.types import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -16,6 +17,7 @@ import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.impl.* import org.jetbrains.kotlin.ir.util.defaultType +import org.jetbrains.kotlin.ir.util.isPropertyAccessor import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.makeNullable @@ -155,13 +157,28 @@ val IrClassSymbol.starProjectedType: IrSimpleType ) val IrClass.typeConstructorParameters: Sequence - get() = generateSequence(this as IrTypeParametersContainer, - { current -> - val parent = current.parent as? IrTypeParametersContainer - if (parent is IrClass && current is IrClass && !current.isInner) null - else parent - }) - .flatMap { it.typeParameters } + get() = + generateSequence( + this as IrTypeParametersContainer, + { current -> + val parent = current.parent as? IrTypeParametersContainer + when { + parent is IrSimpleFunction && parent.isPropertyAccessor -> { + // KT-42151 + // Property type parameters for local classes declared inside property accessors are not captured in FE descriptors. + // In order to match type parameters against type arguments in IR types translated from KotlinTypes, + // we should stop on property accessor here. + // NB this can potentially cause problems with inline properties with reified type parameters. + // Ideally this should be fixed in FE. + null + } + parent is IrClass && current is IrClass && !current.isInner -> + null + else -> + parent + } + } + ).flatMap { it.typeParameters } fun IrClassifierSymbol.typeWithParameters(parameters: List): IrSimpleType = typeWith(parameters.map { it.defaultType }) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt index 2f8ba09729c..2d65573733f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt @@ -526,7 +526,16 @@ fun IrMemberAccessExpression<*>.getTypeSubstitutionMap(irFunction: IrFunction): val result = mutableMapOf() if (dispatchReceiverTypeArguments.isNotEmpty()) { - val parentTypeParameters = extractTypeParameters(irFunction.parentClassOrNull!!) + val parentTypeParameters = + if (irFunction is IrConstructor) { + val constructedClass = irFunction.parentAsClass + if (!constructedClass.isInner && dispatchReceiver != null) { + throw AssertionError("Non-inner class constructor reference with dispatch receiver:\n${this.dump()}") + } + extractTypeParameters(constructedClass.parent as IrClass) + } else { + extractTypeParameters(irFunction.parentClassOrNull!!) + } parentTypeParameters.withIndex().forEach { (index, typeParam) -> dispatchReceiverTypeArguments[index].typeOrNull?.let { result[typeParam.symbol] = it diff --git a/compiler/testData/codegen/box/callableReference/genericConstructorReference.kt b/compiler/testData/codegen/box/callableReference/genericConstructorReference.kt index 982b28b4c68..3b3b633a62e 100644 --- a/compiler/testData/codegen/box/callableReference/genericConstructorReference.kt +++ b/compiler/testData/codegen/box/callableReference/genericConstructorReference.kt @@ -1,7 +1,6 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: BINDING_RECEIVERS -// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND_FIR: JVM_IR // KT-42025 diff --git a/compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt b/compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt new file mode 100644 index 00000000000..0311bf04fca --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt @@ -0,0 +1,25 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: BINDING_RECEIVERS + +// IGNORE_BACKEND_FIR: JVM_IR +// KT-42025 + +open class L(val ll: LL) + +class Rec(val rt: T) + +fun Rec.fn(): L { + class FLocal(lt: LT, val pt: FT): L(lt) + return foo2(rt, rt, ::FLocal) +} + +val Rec.p: L + get() { + class PLocal(lt: LT, val pt: PT): L(lt) + return foo2(rt, rt, ::PLocal) + } + +fun foo2(t1: T1, t2: T2, bb: (T1, T2) -> R): R = bb(t1, t2) + +fun box(): String = + Rec("O").fn().ll + Rec("K").p.ll \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.kt.txt new file mode 100644 index 00000000000..d454c6a0216 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.kt.txt @@ -0,0 +1,64 @@ +open class L { + constructor(ll: LL) /* primary */ { + super/*Any*/() + /* () */ + + } + + val ll: LL + field = ll + get + +} + +class Rec { + constructor(rt: T) /* primary */ { + super/*Any*/() + /* () */ + + } + + val rt: T + field = rt + get + +} + +val Rec.p: L + get(): L { + local class PLocal : L { + constructor(lt: LT, pt: PT) /* primary */ { + super/*L*/(ll = lt) + /* () */ + + } + + val pt: PT + field = pt + get + + } + + return foo2>(t1 = .(), t2 = .(), bb = PLocal::/*()*/) + } + +fun Rec.fn(): L { + local class FLocal : L { + constructor(lt: LT, pt: FT) /* primary */ { + super/*L*/(ll = lt) + /* () */ + + } + + val pt: FT + field = pt + get + + } + + return foo2>(t1 = .(), t2 = .(), bb = FLocal::/*()*/) +} + +fun foo2(t1: T1, t2: T2, bb: Function2): R { + return bb.invoke(p1 = t1, p2 = t2) +} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt new file mode 100644 index 00000000000..446c9cdb584 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt @@ -0,0 +1,192 @@ +FILE fqName: fileName:/genericLocalClassConstructorReference.kt + CLASS CLASS name:L modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.L.L> + TYPE_PARAMETER name:LL index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (ll:LL of .L) returnType:.L.L> [primary] + VALUE_PARAMETER name:ll index:0 type:LL of .L + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:L modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:ll visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:ll type:LL of .L visibility:private [final] + EXPRESSION_BODY + GET_VAR 'll: LL of .L declared in .L.' type=LL of .L origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.L.L>) returnType:LL of .L + correspondingProperty: PROPERTY name:ll visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.L.L> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): LL of .L declared in .L' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ll type:LL of .L visibility:private [final]' type=LL of .L origin=null + receiver: GET_VAR ': .L.L> declared in .L.' type=.L.L> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Rec modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Rec.Rec> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (rt:T of .Rec) returnType:.Rec.Rec> [primary] + VALUE_PARAMETER name:rt index:0 type:T of .Rec + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Rec modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:rt visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:rt type:T of .Rec visibility:private [final] + EXPRESSION_BODY + GET_VAR 'rt: T of .Rec declared in .Rec.' type=T of .Rec origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Rec.Rec>) returnType:T of .Rec + correspondingProperty: PROPERTY name:rt visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Rec.Rec> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of .Rec declared in .Rec' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rt type:T of .Rec visibility:private [final]' type=T of .Rec origin=null + receiver: GET_VAR ': .Rec.Rec> declared in .Rec.' type=.Rec.Rec> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:p visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL ($receiver:.Rec.>) returnType:.L.> + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [val] + TYPE_PARAMETER name:PT index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Rec.> + BLOCK_BODY + CLASS CLASS name:PLocal modality:FINAL visibility:local superTypes:[.L..PLocal>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:..PLocal..PLocal> + TYPE_PARAMETER name:LT index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (lt:LT of ..PLocal, pt:PT of .) returnType:..PLocal..PLocal> [primary] + VALUE_PARAMETER name:lt index:0 type:LT of ..PLocal + VALUE_PARAMETER name:pt index:1 type:PT of . + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor (ll: LL of .L) [primary] declared in .L' + : LT of ..PLocal + ll: GET_VAR 'lt: LT of ..PLocal declared in ..PLocal.' type=LT of ..PLocal origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:PLocal modality:FINAL visibility:local superTypes:[.L..PLocal>]' + PROPERTY name:pt visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:pt type:PT of . visibility:private [final] + EXPRESSION_BODY + GET_VAR 'pt: PT of . declared in ..PLocal.' type=PT of . origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:..PLocal..PLocal>) returnType:PT of . + correspondingProperty: PROPERTY name:pt visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:..PLocal..PLocal> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): PT of . declared in ..PLocal' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:pt type:PT of . visibility:private [final]' type=PT of . origin=null + receiver: GET_VAR ': ..PLocal..PLocal> declared in ..PLocal.' type=..PLocal..PLocal> origin=null + PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.L.L>) returnType:LT of ..PLocal [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): LL of .L declared in .L + $this: VALUE_PARAMETER name: type:.L.L> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + RETURN type=kotlin.Nothing from='public final fun (): .L.> declared in ' + CALL 'public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' type=..PLocal.> origin=null + : PT of . + : PT of . + : ..PLocal.> + t1: CALL 'public final fun (): T of .Rec declared in .Rec' type=PT of . origin=GET_PROPERTY + $this: GET_VAR ': .Rec.> declared in .' type=.Rec.> origin=null + t2: CALL 'public final fun (): T of .Rec declared in .Rec' type=PT of . origin=GET_PROPERTY + $this: GET_VAR ': .Rec.> declared in .' type=.Rec.> origin=null + bb: FUNCTION_REFERENCE 'public constructor (lt: LT of ..PLocal, pt: PT of .) [primary] declared in ..PLocal' type=kotlin.reflect.KFunction2., PT of ., ..PLocal.>> origin=null reflectionTarget= + : PT of . + FUN name:fn visibility:public modality:FINAL ($receiver:.Rec.fn>) returnType:.L.fn> + TYPE_PARAMETER name:FT index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Rec.fn> + BLOCK_BODY + CLASS CLASS name:FLocal modality:FINAL visibility:local superTypes:[.L.fn.FLocal>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.fn.FLocal.fn.FLocal> + TYPE_PARAMETER name:LT index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (lt:LT of .fn.FLocal, pt:FT of .fn) returnType:.fn.FLocal.fn.FLocal> [primary] + VALUE_PARAMETER name:lt index:0 type:LT of .fn.FLocal + VALUE_PARAMETER name:pt index:1 type:FT of .fn + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor (ll: LL of .L) [primary] declared in .L' + : LT of .fn.FLocal + ll: GET_VAR 'lt: LT of .fn.FLocal declared in .fn.FLocal.' type=LT of .fn.FLocal origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FLocal modality:FINAL visibility:local superTypes:[.L.fn.FLocal>]' + PROPERTY name:pt visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:pt type:FT of .fn visibility:private [final] + EXPRESSION_BODY + GET_VAR 'pt: FT of .fn declared in .fn.FLocal.' type=FT of .fn origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.fn.FLocal.fn.FLocal>) returnType:FT of .fn + correspondingProperty: PROPERTY name:pt visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.fn.FLocal.fn.FLocal> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): FT of .fn declared in .fn.FLocal' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:pt type:FT of .fn visibility:private [final]' type=FT of .fn origin=null + receiver: GET_VAR ': .fn.FLocal.fn.FLocal> declared in .fn.FLocal.' type=.fn.FLocal.fn.FLocal> origin=null + PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.L.L>) returnType:LT of .fn.FLocal [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): LL of .L declared in .L + $this: VALUE_PARAMETER name: type:.L.L> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + RETURN type=kotlin.Nothing from='public final fun fn (): .L.fn> declared in ' + CALL 'public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' type=.fn.FLocal.fn> origin=null + : FT of .fn + : FT of .fn + : .fn.FLocal.fn> + t1: CALL 'public final fun (): T of .Rec declared in .Rec' type=FT of .fn origin=GET_PROPERTY + $this: GET_VAR ': .Rec.fn> declared in .fn' type=.Rec.fn> origin=null + t2: CALL 'public final fun (): T of .Rec declared in .Rec' type=FT of .fn origin=GET_PROPERTY + $this: GET_VAR ': .Rec.fn> declared in .fn' type=.Rec.fn> origin=null + bb: FUNCTION_REFERENCE 'public constructor (lt: LT of .fn.FLocal, pt: FT of .fn) [primary] declared in .fn.FLocal' type=kotlin.reflect.KFunction2.fn, FT of .fn, .fn.FLocal.fn>> origin=null reflectionTarget= + : FT of .fn + FUN name:foo2 visibility:public modality:FINAL (t1:T1 of .foo2, t2:T2 of .foo2, bb:kotlin.Function2.foo2, T2 of .foo2, R of .foo2>) returnType:R of .foo2 + TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:T2 index:1 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:R index:2 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:t1 index:0 type:T1 of .foo2 + VALUE_PARAMETER name:t2 index:1 type:T2 of .foo2 + VALUE_PARAMETER name:bb index:2 type:kotlin.Function2.foo2, T2 of .foo2, R of .foo2> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=R of .foo2 origin=INVOKE + $this: GET_VAR 'bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2> declared in .foo2' type=kotlin.Function2.foo2, T2 of .foo2, R of .foo2> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR 't1: T1 of .foo2 declared in .foo2' type=T1 of .foo2 origin=null + p2: GET_VAR 't2: T2 of .foo2 declared in .foo2' type=T2 of .foo2 origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt new file mode 100644 index 00000000000..d76e23d033a --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt @@ -0,0 +1,16 @@ +open class L(val ll: LL) + +class Rec(val rt: T) + +val Rec.p: L + get() { + class PLocal(lt: LT, val pt: PT): L(lt) + return foo2(rt, rt, ::PLocal) + } + +fun Rec.fn(): L { + class FLocal(lt: LT, val pt: FT) : L(lt) + return foo2(rt, rt, ::FLocal) +} + +fun foo2(t1: T1, t2: T2, bb: (T1, T2) -> R): R = bb(t1, t2) \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt.txt new file mode 100644 index 00000000000..1411fda426f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt.txt @@ -0,0 +1,64 @@ +open class L { + constructor(ll: LL) /* primary */ { + super/*Any*/() + /* () */ + + } + + val ll: LL + field = ll + get + +} + +class Rec { + constructor(rt: T) /* primary */ { + super/*Any*/() + /* () */ + + } + + val rt: T + field = rt + get + +} + +val Rec.p: L + get(): L { + local class PLocal : L { + constructor(lt: LT, pt: PT) /* primary */ { + super/*L*/(ll = lt) + /* () */ + + } + + val pt: PT + field = pt + get + + } + + return foo2>(t1 = .(), t2 = .(), bb = PLocal::/*()*/) + } + +fun Rec.fn(): L { + local class FLocal : L { + constructor(lt: LT, pt: FT) /* primary */ { + super/*L*/(ll = lt) + /* () */ + + } + + val pt: FT + field = pt + get + + } + + return foo2>(t1 = .(), t2 = .(), bb = FLocal::/*()*/) +} + +fun foo2(t1: T1, t2: T2, bb: Function2): R { + return bb.invoke(p1 = t1, p2 = t2) +} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.txt new file mode 100644 index 00000000000..0a22b28a06f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.txt @@ -0,0 +1,192 @@ +FILE fqName: fileName:/genericLocalClassConstructorReference.kt + CLASS CLASS name:L modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.L.L> + TYPE_PARAMETER name:LL index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (ll:LL of .L) returnType:.L.L> [primary] + VALUE_PARAMETER name:ll index:0 type:LL of .L + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:L modality:OPEN visibility:public superTypes:[kotlin.Any]' + PROPERTY name:ll visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:ll type:LL of .L visibility:private [final] + EXPRESSION_BODY + GET_VAR 'll: LL of .L declared in .L.' type=LL of .L origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.L.L>) returnType:LL of .L + correspondingProperty: PROPERTY name:ll visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.L.L> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): LL of .L declared in .L' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ll type:LL of .L visibility:private [final]' type=LL of .L origin=null + receiver: GET_VAR ': .L.L> declared in .L.' type=.L.L> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Rec modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Rec.Rec> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (rt:T of .Rec) returnType:.Rec.Rec> [primary] + VALUE_PARAMETER name:rt index:0 type:T of .Rec + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Rec modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:rt visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:rt type:T of .Rec visibility:private [final] + EXPRESSION_BODY + GET_VAR 'rt: T of .Rec declared in .Rec.' type=T of .Rec origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Rec.Rec>) returnType:T of .Rec + correspondingProperty: PROPERTY name:rt visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Rec.Rec> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of .Rec declared in .Rec' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:rt type:T of .Rec visibility:private [final]' type=T of .Rec origin=null + receiver: GET_VAR ': .Rec.Rec> declared in .Rec.' type=.Rec.Rec> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:p visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL ($receiver:.Rec.>) returnType:.L.> + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [val] + TYPE_PARAMETER name:PT index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Rec.> + BLOCK_BODY + CLASS CLASS name:PLocal modality:FINAL visibility:local superTypes:[.L..PLocal>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:..PLocal..PLocal> + TYPE_PARAMETER name:LT index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (lt:LT of ..PLocal, pt:PT of .) returnType:..PLocal..PLocal> [primary] + VALUE_PARAMETER name:lt index:0 type:LT of ..PLocal + VALUE_PARAMETER name:pt index:1 type:PT of . + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor (ll: LL of .L) [primary] declared in .L' + : LT of ..PLocal + ll: GET_VAR 'lt: LT of ..PLocal declared in ..PLocal.' type=LT of ..PLocal origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:PLocal modality:FINAL visibility:local superTypes:[.L..PLocal>]' + PROPERTY name:pt visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:pt type:PT of . visibility:private [final] + EXPRESSION_BODY + GET_VAR 'pt: PT of . declared in ..PLocal.' type=PT of . origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:..PLocal..PLocal>) returnType:PT of . + correspondingProperty: PROPERTY name:pt visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:..PLocal..PLocal> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): PT of . declared in ..PLocal' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:pt type:PT of . visibility:private [final]' type=PT of . origin=null + receiver: GET_VAR ': ..PLocal..PLocal> declared in ..PLocal.' type=..PLocal..PLocal> origin=null + PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.L..PLocal>) returnType:LT of ..PLocal [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): LL of .L declared in .L + $this: VALUE_PARAMETER name: type:.L..PLocal> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .L + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .L + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .L + $this: VALUE_PARAMETER name: type:kotlin.Any + RETURN type=kotlin.Nothing from='public final fun (): .L.> declared in ' + CALL 'public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' type=..PLocal.> origin=null + : PT of . + : PT of . + : ..PLocal.> + t1: CALL 'public final fun (): T of .Rec declared in .Rec' type=PT of . origin=GET_PROPERTY + $this: GET_VAR ': .Rec.> declared in .' type=.Rec.> origin=null + t2: CALL 'public final fun (): T of .Rec declared in .Rec' type=PT of . origin=GET_PROPERTY + $this: GET_VAR ': .Rec.> declared in .' type=.Rec.> origin=null + bb: FUNCTION_REFERENCE 'public constructor (lt: LT of ..PLocal, pt: PT of .) [primary] declared in ..PLocal' type=kotlin.reflect.KFunction2., PT of ., ..PLocal.>> origin=null reflectionTarget= + : PT of . + FUN name:fn visibility:public modality:FINAL ($receiver:.Rec.fn>) returnType:.L.fn> + TYPE_PARAMETER name:FT index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Rec.fn> + BLOCK_BODY + CLASS CLASS name:FLocal modality:FINAL visibility:local superTypes:[.L.fn.FLocal>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.fn.FLocal.fn.FLocal, FT of .fn> + TYPE_PARAMETER name:LT index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (lt:LT of .fn.FLocal, pt:FT of .fn) returnType:.fn.FLocal.fn.FLocal, FT of .fn> [primary] + VALUE_PARAMETER name:lt index:0 type:LT of .fn.FLocal + VALUE_PARAMETER name:pt index:1 type:FT of .fn + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor (ll: LL of .L) [primary] declared in .L' + : LT of .fn.FLocal + ll: GET_VAR 'lt: LT of .fn.FLocal declared in .fn.FLocal.' type=LT of .fn.FLocal origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FLocal modality:FINAL visibility:local superTypes:[.L.fn.FLocal>]' + PROPERTY name:pt visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:pt type:FT of .fn visibility:private [final] + EXPRESSION_BODY + GET_VAR 'pt: FT of .fn declared in .fn.FLocal.' type=FT of .fn origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.fn.FLocal.fn.FLocal, FT of .fn>) returnType:FT of .fn + correspondingProperty: PROPERTY name:pt visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.fn.FLocal.fn.FLocal, FT of .fn> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): FT of .fn declared in .fn.FLocal' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:pt type:FT of .fn visibility:private [final]' type=FT of .fn origin=null + receiver: GET_VAR ': .fn.FLocal.fn.FLocal, FT of .fn> declared in .fn.FLocal.' type=.fn.FLocal.fn.FLocal, FT of .fn> origin=null + PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.L.fn.FLocal>) returnType:LT of .fn.FLocal [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ll visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): LL of .L declared in .L + $this: VALUE_PARAMETER name: type:.L.fn.FLocal> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .L + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .L + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .L + $this: VALUE_PARAMETER name: type:kotlin.Any + RETURN type=kotlin.Nothing from='public final fun fn (): .L.fn> declared in ' + CALL 'public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' type=.fn.FLocal.fn, FT of .fn> origin=null + : FT of .fn + : FT of .fn + : .fn.FLocal.fn, FT of .fn> + t1: CALL 'public final fun (): T of .Rec declared in .Rec' type=FT of .fn origin=GET_PROPERTY + $this: GET_VAR ': .Rec.fn> declared in .fn' type=.Rec.fn> origin=null + t2: CALL 'public final fun (): T of .Rec declared in .Rec' type=FT of .fn origin=GET_PROPERTY + $this: GET_VAR ': .Rec.fn> declared in .fn' type=.Rec.fn> origin=null + bb: FUNCTION_REFERENCE 'public constructor (lt: LT of .fn.FLocal, pt: FT of .fn) [primary] declared in .fn.FLocal' type=kotlin.reflect.KFunction2.fn, FT of .fn, .fn.FLocal.fn, FT of .fn>> origin=null reflectionTarget= + : FT of .fn + FUN name:foo2 visibility:public modality:FINAL (t1:T1 of .foo2, t2:T2 of .foo2, bb:kotlin.Function2.foo2, T2 of .foo2, R of .foo2>) returnType:R of .foo2 + TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:T2 index:1 variance: superTypes:[kotlin.Any?] + TYPE_PARAMETER name:R index:2 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:t1 index:0 type:T1 of .foo2 + VALUE_PARAMETER name:t2 index:1 type:T2 of .foo2 + VALUE_PARAMETER name:bb index:2 type:kotlin.Function2.foo2, T2 of .foo2, R of .foo2> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=R of .foo2 origin=INVOKE + $this: GET_VAR 'bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2> declared in .foo2' type=kotlin.Function2.foo2, T2 of .foo2, R of .foo2> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR 't1: T1 of .foo2 declared in .foo2' type=T1 of .foo2 origin=null + p2: GET_VAR 't2: T2 of .foo2 declared in .foo2' type=T2 of .foo2 origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 42f25c74327..7efe75445da 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2058,6 +2058,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("javaField.kt") public void testJavaField() throws Exception { runTest("compiler/testData/codegen/box/callableReference/javaField.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 4444e915f13..c2f808a05e0 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2058,6 +2058,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("javaField.kt") public void testJavaField() throws Exception { runTest("compiler/testData/codegen/box/callableReference/javaField.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 1e77305d909..f0d1879aff3 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -2038,6 +2038,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("javaField.kt") public void testJavaField() throws Exception { runTest("compiler/testData/codegen/box/callableReference/javaField.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 3a4d521ad53..637604c5043 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1498,6 +1498,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("genericMember.kt") public void testGenericMember() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/genericMember.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index fc7bc2148a2..07e72051ebe 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -1468,6 +1468,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("kt37604.kt") public void testKt37604() throws Exception { runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index e5d615e4de6..96c6229aec8 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1468,6 +1468,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("kt37604.kt") public void testKt37604() throws Exception { runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index d9c97517bb6..77ac1fe9313 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1468,6 +1468,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/genericConstructorReference.kt"); } + @TestMetadata("genericLocalClassConstructorReference.kt") + public void testGenericLocalClassConstructorReference() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/genericLocalClassConstructorReference.kt"); + } + @TestMetadata("kt37604.kt") public void testKt37604() throws Exception { runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");