diff --git a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java index 1ad17dc076c..e649c18b14a 100644 --- a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java +++ b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java @@ -47,4 +47,10 @@ public class FirMemberScopeByFqNameTestGenerated extends AbstractFirMemberScopeB public void testMutableList() throws Exception { runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.kt"); } + + @Test + @TestMetadata("overridenFunctionWithGenericBound.kt") + public void testOverridenFunctionWithGenericBound() throws Exception { + runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt"); + } } diff --git a/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt b/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt new file mode 100644 index 00000000000..773cd5f1046 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt @@ -0,0 +1,19 @@ +// DO_NOT_CHECK_SYMBOL_RESTORE +package test + + +interface OtherInterface + +interface TwoParams + +interface MyInterface { + fun funWithOuterAndOwnGenericsAndBounds(tT1: TT1?, tT2: TT2?) + + val TwoParams.propWithOuterAndOwnGenericsAndBounds: T? get() = null +} + +class Foo + +abstract class MyClass : MyInterface + +// class: test/MyClass \ No newline at end of file diff --git a/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.txt b/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.txt new file mode 100644 index 00000000000..e14863aedc5 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.txt @@ -0,0 +1,157 @@ +KtFunctionSymbol: + annotatedType: [] kotlin/Unit + annotationClassIds: [] + annotations: [] + callableIdIfNonLocal: test/MyClass.funWithOuterAndOwnGenericsAndBounds + dispatchType: test/MyClass + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: false + isOverride: false + isStatic: false + isSuspend: false + modality: ABSTRACT + name: funWithOuterAndOwnGenericsAndBounds + origin: SOURCE + receiverType: null + symbolKind: CLASS_MEMBER + typeParameters: [ + KtTypeParameterSymbol(TT1) + KtTypeParameterSymbol(TT2) + ] + valueParameters: [ + KtValueParameterSymbol(tT1) + KtValueParameterSymbol(tT2) + ] + visibility: Public + deprecationStatus: null + +KtKotlinPropertySymbol: + annotatedType: [] test/Foo? + annotationClassIds: [] + annotations: [] + callableIdIfNonLocal: test/MyClass.propWithOuterAndOwnGenericsAndBounds + dispatchType: test/MyClass + getter: null + hasBackingField: false + hasGetter: false + hasSetter: false + initializer: null + isConst: false + isDelegatedProperty: false + isExtension: true + isFromPrimaryConstructor: false + isLateInit: false + isOverride: false + isStatic: false + isVal: true + modality: OPEN + name: propWithOuterAndOwnGenericsAndBounds + origin: SOURCE + receiverType: [] test/TwoParams + setter: null + symbolKind: CLASS_MEMBER + visibility: Public + deprecationStatus: null + getterDeprecationStatus: null + javaGetterName: getPropWithOuterAndOwnGenericsAndBounds + javaSetterName: null + setterDeprecationStatus: null + +KtFunctionSymbol: + annotatedType: [] kotlin/Boolean + annotationClassIds: [] + annotations: [] + callableIdIfNonLocal: kotlin/Any.equals + dispatchType: kotlin/Any + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: true + isOverride: false + isStatic: false + isSuspend: false + modality: OPEN + name: equals + origin: LIBRARY + receiverType: null + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [ + KtValueParameterSymbol(other) + ] + visibility: Public + deprecationStatus: null + +KtFunctionSymbol: + annotatedType: [] kotlin/Int + annotationClassIds: [] + annotations: [] + callableIdIfNonLocal: kotlin/Any.hashCode + dispatchType: kotlin/Any + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: false + isOverride: false + isStatic: false + isSuspend: false + modality: OPEN + name: hashCode + origin: LIBRARY + receiverType: null + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [] + visibility: Public + deprecationStatus: null + +KtFunctionSymbol: + annotatedType: [] kotlin/String + annotationClassIds: [] + annotations: [] + callableIdIfNonLocal: kotlin/Any.toString + dispatchType: kotlin/Any + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: false + isOverride: false + isStatic: false + isSuspend: false + modality: OPEN + name: toString + origin: LIBRARY + receiverType: null + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [] + visibility: Public + deprecationStatus: null + +KtConstructorSymbol: + annotatedType: [] test/MyClass + annotationClassIds: [] + annotations: [] + callableIdIfNonLocal: null + containingClassIdIfNonLocal: test/MyClass + dispatchType: null + hasStableParameterNames: true + isExtension: false + isPrimary: true + origin: SOURCE_MEMBER_GENERATED + receiverType: null + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [] + visibility: Public + deprecationStatus: null diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index b3cdd6b6955..2be4f08625e 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -255,6 +255,7 @@ class FirClassSubstitutionScope( ) private fun createSubstitutedData(member: FirCallableDeclaration): SubstitutedData { + member.ensureResolved(FirResolvePhase.TYPES) val (newTypeParameters, substitutor) = FirFakeOverrideGenerator.createNewTypeParametersAndSubstitutor( session, member as FirTypeParameterRefsOwner, @@ -267,7 +268,7 @@ class FirClassSubstitutionScope( val newDispatchReceiverType = dispatchReceiverTypeForSubstitutedMembers.substitute(substitutor) - member.symbol.ensureResolved(FirResolvePhase.STATUS) + member.ensureResolved(FirResolvePhase.STATUS) val returnType = member.returnTypeRef.coneTypeSafe() val fakeOverrideSubstitution = runIf(returnType == null) { FakeOverrideSubstitution(substitutor, member.symbol) } val newReturnType = returnType?.substitute(substitutor)