[FIR] Add missing ensureResolved to FirClassSubstitutionScope
`createNewTypeParametersAndSubstitutor` call might need resolved types to be able to work correctly with the generics' type bounds
This commit is contained in:
committed by
TeamCityServer
parent
534beb8553
commit
29bb8cea8f
+6
@@ -47,4 +47,10 @@ public class FirMemberScopeByFqNameTestGenerated extends AbstractFirMemberScopeB
|
|||||||
public void testMutableList() throws Exception {
|
public void testMutableList() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.kt");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// DO_NOT_CHECK_SYMBOL_RESTORE
|
||||||
|
package test
|
||||||
|
|
||||||
|
|
||||||
|
interface OtherInterface
|
||||||
|
|
||||||
|
interface TwoParams<T, TT>
|
||||||
|
|
||||||
|
interface MyInterface<T> {
|
||||||
|
fun <TT1 : T, TT2 : OtherInterface> funWithOuterAndOwnGenericsAndBounds(tT1: TT1?, tT2: TT2?)
|
||||||
|
|
||||||
|
val <TT1 : T, TT2 : OtherInterface> TwoParams<TT1, TT2>.propWithOuterAndOwnGenericsAndBounds: T? get() = null
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo
|
||||||
|
|
||||||
|
abstract class MyClass : MyInterface<Foo>
|
||||||
|
|
||||||
|
// class: test/MyClass
|
||||||
Vendored
+157
@@ -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<TT1, TT2>
|
||||||
|
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
|
||||||
+2
-1
@@ -255,6 +255,7 @@ class FirClassSubstitutionScope(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private fun createSubstitutedData(member: FirCallableDeclaration): SubstitutedData {
|
private fun createSubstitutedData(member: FirCallableDeclaration): SubstitutedData {
|
||||||
|
member.ensureResolved(FirResolvePhase.TYPES)
|
||||||
val (newTypeParameters, substitutor) = FirFakeOverrideGenerator.createNewTypeParametersAndSubstitutor(
|
val (newTypeParameters, substitutor) = FirFakeOverrideGenerator.createNewTypeParametersAndSubstitutor(
|
||||||
session,
|
session,
|
||||||
member as FirTypeParameterRefsOwner,
|
member as FirTypeParameterRefsOwner,
|
||||||
@@ -267,7 +268,7 @@ class FirClassSubstitutionScope(
|
|||||||
|
|
||||||
val newDispatchReceiverType = dispatchReceiverTypeForSubstitutedMembers.substitute(substitutor)
|
val newDispatchReceiverType = dispatchReceiverTypeForSubstitutedMembers.substitute(substitutor)
|
||||||
|
|
||||||
member.symbol.ensureResolved(FirResolvePhase.STATUS)
|
member.ensureResolved(FirResolvePhase.STATUS)
|
||||||
val returnType = member.returnTypeRef.coneTypeSafe<ConeKotlinType>()
|
val returnType = member.returnTypeRef.coneTypeSafe<ConeKotlinType>()
|
||||||
val fakeOverrideSubstitution = runIf(returnType == null) { FakeOverrideSubstitution(substitutor, member.symbol) }
|
val fakeOverrideSubstitution = runIf(returnType == null) { FakeOverrideSubstitution(substitutor, member.symbol) }
|
||||||
val newReturnType = returnType?.substitute(substitutor)
|
val newReturnType = returnType?.substitute(substitutor)
|
||||||
|
|||||||
Reference in New Issue
Block a user