diff --git a/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt b/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt index 61a03723943..ec0b5a23300 100644 --- a/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.fir.txt @@ -16,22 +16,22 @@ FILE: referenceToExtension.kt super() } - public final val memberVal: R|GenericTest.A| = R|SubstitutionOverride|() + public final val memberVal: R|GenericTest.A| = R|/GenericTest.A.A|() public get(): R|GenericTest.A| public final fun memberFun(): R|GenericTest.A| { - ^memberFun R|SubstitutionOverride|() + ^memberFun R|/GenericTest.A.A|() } } public final val R|GenericTest.B|.extensionVal: R|GenericTest.A| public get(): R|GenericTest.A| { - ^ R|SubstitutionOverride|() + ^ R|/GenericTest.A.A|() } public final fun R|GenericTest.B|.extensionFun(): R|GenericTest.A| { - ^extensionFun R|SubstitutionOverride|() + ^extensionFun R|/GenericTest.A.A|() } public final fun test_1(): R|kotlin/Unit| { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt index 9ea849211d8..2e713500aa6 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt @@ -31,10 +31,15 @@ abstract class FirNestedClassifierScope(val klass: FirClass, val useSiteSession: processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit ) { val matchedClass = getNestedClassSymbol(name) ?: return - val substitution = klass.typeParameters.associate { - it.symbol to it.toConeType() + val substitutor = if (klass.typeParameters.isEmpty()) { + ConeSubstitutor.Empty + } else { + val substitution = klass.typeParameters.associate { + it.symbol to it.toConeType() + } + ConeSubstitutorByMap(substitution, useSiteSession) } - processor(matchedClass, ConeSubstitutorByMap(substitution, useSiteSession)) + processor(matchedClass, substitutor) } abstract fun isEmpty(): Boolean diff --git a/compiler/testData/codegen/box/fir/TypeParameterInNestedClass.kt b/compiler/testData/codegen/box/fir/TypeParameterInNestedClass.kt index 628b1fddaec..4d6ad22de06 100644 --- a/compiler/testData/codegen/box/fir/TypeParameterInNestedClass.kt +++ b/compiler/testData/codegen/box/fir/TypeParameterInNestedClass.kt @@ -1,7 +1,6 @@ // WITH_STDLIB // WITH_COROUTINES // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_K2: JVM_IR // ISSUE: KT-58008 import kotlin.coroutines.* diff --git a/compiler/testData/ir/irText/firProblems/TypeParameterInNestedClass.fir.ir.txt b/compiler/testData/ir/irText/firProblems/TypeParameterInNestedClass.fir.ir.txt new file mode 100644 index 00000000000..2b3d88734fb --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/TypeParameterInNestedClass.fir.ir.txt @@ -0,0 +1,69 @@ +FILE fqName: fileName:/TypeParameterInNestedClass.kt + CLASS OBJECT name:Retry modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Retry + CONSTRUCTOR visibility:private <> () returnType:.Retry [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Retry modality:FINAL visibility:public superTypes:[kotlin.Any]' + CLASS CLASS name:Builder modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Retry.Builder.Retry.Builder> + TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (action:kotlin.coroutines.SuspendFunction0.Retry.Builder>) returnType:.Retry.Builder.Retry.Builder> [primary] + VALUE_PARAMETER name:action index:0 type:kotlin.coroutines.SuspendFunction0.Retry.Builder> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Builder modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:action visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:action type:kotlin.coroutines.SuspendFunction0.Retry.Builder> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'action: kotlin.coroutines.SuspendFunction0.Retry.Builder> declared in .Retry.Builder.' type=kotlin.coroutines.SuspendFunction0.Retry.Builder> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.Retry.Builder.Retry.Builder>) returnType:kotlin.coroutines.SuspendFunction0.Retry.Builder> + correspondingProperty: PROPERTY name:action visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Retry.Builder.Retry.Builder> + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): kotlin.coroutines.SuspendFunction0.Retry.Builder> declared in .Retry.Builder' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:action type:kotlin.coroutines.SuspendFunction0.Retry.Builder> visibility:private [final]' type=kotlin.coroutines.SuspendFunction0.Retry.Builder> origin=null + receiver: GET_VAR ': .Retry.Builder.Retry.Builder> declared in .Retry.Builder.' type=.Retry.Builder.Retry.Builder> 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 + FUN name:withExponentialBackoff visibility:public modality:FINAL ($this:.Retry, action:kotlin.Function0.Retry.withExponentialBackoff>) returnType:.Retry.Builder.Retry.withExponentialBackoff> + TYPE_PARAMETER name:W index:0 variance: superTypes:[kotlin.Any?] reified:false + $this: VALUE_PARAMETER name: type:.Retry + VALUE_PARAMETER name:action index:0 type:kotlin.Function0.Retry.withExponentialBackoff> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withExponentialBackoff (action: kotlin.Function0.Retry.withExponentialBackoff>): .Retry.Builder.Retry.withExponentialBackoff> declared in .Retry' + CONSTRUCTOR_CALL 'public constructor (action: kotlin.coroutines.SuspendFunction0.Retry.Builder>) [primary] declared in .Retry.Builder' type=.Retry.Builder.Retry.withExponentialBackoff> origin=null + : W of .Retry.withExponentialBackoff + action: BLOCK type=kotlin.coroutines.SuspendFunction0.Retry.Builder> origin=SUSPEND_CONVERSION + FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion visibility:local modality:FINAL <> ($receiver:kotlin.Function0.Retry.withExponentialBackoff>) returnType:B of .Retry.Builder [suspend] + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0.Retry.withExponentialBackoff> + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun suspendConversion (): B of .Retry.Builder [suspend] declared in .Retry.withExponentialBackoff' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=B of .Retry.Builder origin=null + $this: GET_VAR 'callee: kotlin.Function0.Retry.withExponentialBackoff> declared in .Retry.withExponentialBackoff.suspendConversion' type=kotlin.Function0.Retry.withExponentialBackoff> origin=null + FUNCTION_REFERENCE 'local final fun suspendConversion (): B of .Retry.Builder [suspend] declared in .Retry.withExponentialBackoff' type=kotlin.coroutines.SuspendFunction0.Retry.Builder> origin=SUSPEND_CONVERSION reflectionTarget=null + $receiver: GET_VAR 'action: kotlin.Function0.Retry.withExponentialBackoff> declared in .Retry.withExponentialBackoff' type=kotlin.Function0.Retry.withExponentialBackoff> 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 diff --git a/compiler/testData/ir/irText/firProblems/TypeParameterInNestedClass.fir.kt.txt b/compiler/testData/ir/irText/firProblems/TypeParameterInNestedClass.fir.kt.txt new file mode 100644 index 00000000000..cd6ab388ead --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/TypeParameterInNestedClass.fir.kt.txt @@ -0,0 +1,31 @@ +object Retry { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + class Builder { + constructor(action: SuspendFunction0) /* primary */ { + super/*Any*/() + /* () */ + + } + + private val action: SuspendFunction0 + field = action + private get + + } + + fun withExponentialBackoff(action: Function0): Builder { + return Builder(action = { // BLOCK + local suspend fun Function0.suspendConversion(): B { + return callee.invoke() + } + + action::suspendConversion + }) + } + +}