[FIR] Split origin SubstitutionOverride into declaration and call-site
This commit is contained in:
committed by
Space Team
parent
67fc46a190
commit
bcdd85758e
+1
-1
@@ -24,7 +24,7 @@ internal class JavaClassDeclaredMembersEnhancementScope(
|
||||
) : FirContainingNamesAwareScope() {
|
||||
private fun FirCallableDeclaration.isDeclared(): Boolean {
|
||||
return (this.dispatchReceiverType as? ConeLookupTagBasedType)?.lookupTag == owner.symbol.toLookupTag()
|
||||
&& this.origin != FirDeclarationOrigin.SubstitutionOverride
|
||||
&& this.origin !is FirDeclarationOrigin.SubstitutionOverride
|
||||
&& this.origin != FirDeclarationOrigin.IntersectionOverride
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ internal tailrec fun FirDeclaration.ktSymbolOrigin(): KtSymbolOrigin = when (ori
|
||||
|
||||
is FirDeclarationOrigin.Plugin -> KtSymbolOrigin.PLUGIN
|
||||
FirDeclarationOrigin.RenamedForOverride -> KtSymbolOrigin.JAVA
|
||||
FirDeclarationOrigin.SubstitutionOverride -> KtSymbolOrigin.SUBSTITUTION_OVERRIDE
|
||||
is FirDeclarationOrigin.SubstitutionOverride -> KtSymbolOrigin.SUBSTITUTION_OVERRIDE
|
||||
FirDeclarationOrigin.DynamicScope -> buildErrorWithAttachment("Invalid FirDeclarationOrigin ${origin::class.simpleName}") {
|
||||
withFirEntry("firToGetOrigin", this@ktSymbolOrigin)
|
||||
}
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ private fun collectDesignationPath(target: FirElementWithResolveState): List<Fir
|
||||
|
||||
val containingClassId = target.containingClassLookupTag()?.classId ?: return emptyList()
|
||||
|
||||
if (target.origin == FirDeclarationOrigin.SubstitutionOverride) {
|
||||
if (target.origin is FirDeclarationOrigin.SubstitutionOverride) {
|
||||
val originalContainingClassId = target.originalForSubstitutionOverride?.containingClassLookupTag()?.classId
|
||||
if (containingClassId == originalContainingClassId) {
|
||||
// Ugly temporary hack for call-site substitution overrides (KTIJ-24004).
|
||||
|
||||
Vendored
+2
-2
@@ -2,7 +2,7 @@ C:
|
||||
[Source]: public open override fun getName(): R|kotlin/String| from Use site scope of /C [id: 0]
|
||||
[Enhancement]: public abstract fun getName(): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
|
||||
[Source]: public open override fun setName(newName: R|kotlin/String|): R|kotlin/Any?| from Use site scope of /C [id: 0]
|
||||
[SubstitutionOverride]: public abstract fun setName(newName: R|kotlin/String!|): R|kotlin/Any!| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun setName(newName: R|kotlin/String!|): R|kotlin/Any!| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
|
||||
[Enhancement]: public abstract fun setName(newName: R|kotlin/String!|): R|ft<T & Any, T?>| from Java enhancement scope for /B [id: 2]
|
||||
[Source]: private final var name: R|kotlin/String| = R|<local>/name| from Use site scope of /C [id: 0]
|
||||
|
||||
@@ -10,7 +10,7 @@ D:
|
||||
[Source]: public open override fun getName(): R|kotlin/String| from Java enhancement scope for /D [id: 0]
|
||||
[Enhancement]: public abstract fun getName(): R|kotlin/String!| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
|
||||
[Source]: public open override fun setName(newName: R|kotlin/String|): R|kotlin/Any?| from Java enhancement scope for /D [id: 0]
|
||||
[SubstitutionOverride]: public abstract fun setName(newName: R|kotlin/String!|): R|kotlin/Any!| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun setName(newName: R|kotlin/String!|): R|kotlin/Any!| from Substitution scope for [Java enhancement scope for /B] for type C [id: 1]
|
||||
[Enhancement]: public abstract fun setName(newName: R|kotlin/String!|): R|ft<T & Any, T?>| from Java enhancement scope for /B [id: 2]
|
||||
[Source]: private final var name: R|kotlin/String| = R|<local>/name| from Java enhancement scope for /D [id: 0]
|
||||
[Source]: private final var name: R|kotlin/String| = R|<local>/name| from Use site scope of /C [id: 0]
|
||||
|
||||
+14
-14
@@ -1,38 +1,38 @@
|
||||
SomeMap:
|
||||
[Enhancement]: public abstract fun containsKey(key: R|ft<K3 & Any, K3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
|
||||
[SubstitutionOverride]: public abstract fun containsKey(key: R|ft<K3 & Any, K3?>|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsKey(key: R|ft<K3 & Any, K3?>|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[Library]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
|
||||
[Library]: public abstract fun containsKey(key: R|K|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
|
||||
[SubstitutionOverride]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
|
||||
[Enhancement]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 5]
|
||||
[SubstitutionOverride]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 6]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 6]
|
||||
[Enhancement]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyBaseMap [id: 7]
|
||||
[SubstitutionOverride]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 6]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 6]
|
||||
[Enhancement]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyBaseMap [id: 7]
|
||||
[IntersectionOverride]: public abstract fun containsValue(value: R|ft<V3 & Any, V3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
|
||||
[SubstitutionOverride]: public abstract fun containsValue(value: R|ft<V3 & Any, V3?>|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsValue(value: R|ft<V3 & Any, V3?>|): R|kotlin/Boolean| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[Library]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
|
||||
[Library]: public abstract fun containsValue(value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/Map [id: 3]
|
||||
[SubstitutionOverride]: public abstract fun containsValue(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsValue(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
|
||||
[Enhancement]: public abstract fun containsValue(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 5]
|
||||
[IntersectionOverride]: public abstract operator fun get(key: R|ft<K3 & Any, K3?>|): R|V3?| from Java enhancement scope for /SomeMap [id: 0]
|
||||
[SubstitutionOverride]: public abstract operator fun get(key: R|ft<K3 & Any, K3?>|): R|V3?| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun get(key: R|ft<K3 & Any, K3?>|): R|V3?| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[Library]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/Map [id: 3]
|
||||
[Library]: public abstract operator fun get(key: R|K|): R|V?| from Use site scope of kotlin/collections/Map [id: 3]
|
||||
[SubstitutionOverride]: public abstract operator fun get(key: R|ft<K3 & Any, K3?>|): R|ft<V3 & Any, V3?>| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract operator fun get(key: R|ft<K3 & Any, K3?>|): R|ft<V3 & Any, V3?>| from Substitution scope for [Java enhancement scope for /MyMap] for type SomeMap<K3, V3> [id: 4]
|
||||
[Enhancement]: public abstract operator fun get(key: R|ft<K2 & Any, K2?>|): R|ft<V2 & Any, V2?>| from Java enhancement scope for /MyMap [id: 5]
|
||||
[Enhancement]: public abstract fun remove(key: R|ft<K3 & Any, K3?>|): R|V3?| from Java enhancement scope for /SomeMap [id: 0]
|
||||
[SubstitutionOverride]: public abstract fun remove(key: R|ft<K3 & Any, K3?>|): R|V3?| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun remove(key: R|ft<K3 & Any, K3?>|): R|V3?| from Substitution scope for [Use site scope of kotlin/collections/MutableMap] for type SomeMap<K3, V3> [id: 1]
|
||||
[Library]: public abstract fun remove(key: R|K|): R|V?| from Use site scope of kotlin/collections/MutableMap [id: 2]
|
||||
[SubstitutionOverride]: public open fun remove(key: R|ft<K3 & Any, K3?>|, value: R|ft<V3 & Any, V3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
|
||||
[SubstitutionOverride(DeclarationSite)]: public open fun remove(key: R|ft<K3 & Any, K3?>|, value: R|ft<V3 & Any, V3?>|): R|kotlin/Boolean| from Java enhancement scope for /SomeMap [id: 0]
|
||||
[Library]: public open fun remove(key: R|K|, value: R|V|): R|kotlin/Boolean| from Use site scope of kotlin/collections/MutableMap [id: 1]
|
||||
|
||||
MyMap:
|
||||
[Enhancement]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 0]
|
||||
[SubstitutionOverride]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 1]
|
||||
[SubstitutionOverride(DeclarationSite)]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Substitution scope for [Java enhancement scope for /MyBaseMap] for type MyMap<K2, V2> [id: 1]
|
||||
[Enhancement]: public abstract fun containsKey(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyBaseMap [id: 2]
|
||||
[Enhancement]: public abstract fun containsValue(key: R|kotlin/Any!|): R|kotlin/Boolean| from Java enhancement scope for /MyMap [id: 0]
|
||||
[Enhancement]: public abstract operator fun get(key: R|ft<K2 & Any, K2?>|): R|ft<V2 & Any, V2?>| from Java enhancement scope for /MyMap [id: 0]
|
||||
|
||||
+6
-1
@@ -136,6 +136,7 @@ class FakeOverrideGenerator(
|
||||
session, symbol, firFunction,
|
||||
derivedClassLookupTag = firClass.symbol.toLookupTag(),
|
||||
newDispatchReceiverType = firClass.defaultType(),
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride.DeclarationSite,
|
||||
isExpect = (firClass as? FirRegularClass)?.isExpect == true || firFunction.isExpect
|
||||
)
|
||||
},
|
||||
@@ -164,6 +165,7 @@ class FakeOverrideGenerator(
|
||||
session, symbolForOverride, firProperty,
|
||||
derivedClassLookupTag = firClass.symbol.toLookupTag(),
|
||||
newDispatchReceiverType = firClass.defaultType(),
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride.DeclarationSite,
|
||||
isExpect = (firClass as? FirRegularClass)?.isExpect == true || firProperty.isExpect
|
||||
)
|
||||
},
|
||||
@@ -192,6 +194,7 @@ class FakeOverrideGenerator(
|
||||
session, firField,
|
||||
derivedClassLookupTag = firClass.symbol.toLookupTag(),
|
||||
newReturnType = firField.returnTypeRef.coneType,
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride.DeclarationSite,
|
||||
)
|
||||
},
|
||||
baseStaticFieldSymbols,
|
||||
@@ -344,6 +347,7 @@ class FakeOverrideGenerator(
|
||||
session, callableSymbol, firFunction,
|
||||
derivedClassLookupTag = klass.symbol.toLookupTag(),
|
||||
newDispatchReceiverType = klass.defaultType(),
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride.DeclarationSite,
|
||||
isExpect = (klass as? FirRegularClass)?.isExpect == true || firFunction.isExpect
|
||||
)
|
||||
},
|
||||
@@ -363,6 +367,7 @@ class FakeOverrideGenerator(
|
||||
session, callableSymbol, firProperty,
|
||||
derivedClassLookupTag = klass.symbol.toLookupTag(),
|
||||
newDispatchReceiverType = klass.defaultType(),
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride.DeclarationSite,
|
||||
isExpect = (klass as? FirRegularClass)?.isExpect == true || firProperty.isExpect
|
||||
)
|
||||
},
|
||||
@@ -376,7 +381,7 @@ class FakeOverrideGenerator(
|
||||
scope: FirScope,
|
||||
containingClass: ConeClassLikeLookupTag,
|
||||
): List<S> {
|
||||
if (symbol.fir.origin == FirDeclarationOrigin.SubstitutionOverride) {
|
||||
if (symbol.fir.origin is FirDeclarationOrigin.SubstitutionOverride) {
|
||||
return listOf(symbol.originalForSubstitutionOverride!!)
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSessionComponent
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.delegateFields
|
||||
@@ -207,7 +208,12 @@ private fun FirClass.scopeForClassImpl(
|
||||
substitutor.substituteOrSelf(classFirDispatchReceiver.defaultType()).lowerBoundIfFlexible() as ConeClassLikeType,
|
||||
skipPrivateMembers,
|
||||
makeExpect = isFromExpectClass,
|
||||
memberOwnerLookupTag ?: classFirDispatchReceiver.symbol.toLookupTag()
|
||||
memberOwnerLookupTag ?: classFirDispatchReceiver.symbol.toLookupTag(),
|
||||
origin = if (classFirDispatchReceiver != this) {
|
||||
FirDeclarationOrigin.SubstitutionOverride.DeclarationSite
|
||||
} else {
|
||||
FirDeclarationOrigin.SubstitutionOverride.CallSite
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -35,7 +35,8 @@ class FirClassSubstitutionScope(
|
||||
private val dispatchReceiverTypeForSubstitutedMembers: ConeClassLikeType,
|
||||
private val skipPrivateMembers: Boolean,
|
||||
private val makeExpect: Boolean = false,
|
||||
private val derivedClassLookupTag: ConeClassLikeLookupTag
|
||||
private val derivedClassLookupTag: ConeClassLikeLookupTag,
|
||||
private val origin: FirDeclarationOrigin.SubstitutionOverride,
|
||||
) : FirTypeScope() {
|
||||
|
||||
private val substitutionOverrideCache = session.substitutionOverrideStorage.substitutionOverrideCacheByScope.getValue(key, null)
|
||||
@@ -147,6 +148,7 @@ class FirClassSubstitutionScope(
|
||||
derivedClassLookupTag = derivedClassLookupTag,
|
||||
newDispatchReceiverType ?: dispatchReceiverTypeForSubstitutedMembers,
|
||||
isExpect = makeExpect,
|
||||
origin = origin,
|
||||
)
|
||||
}
|
||||
return original
|
||||
@@ -163,6 +165,7 @@ class FirClassSubstitutionScope(
|
||||
member,
|
||||
derivedClassLookupTag,
|
||||
newDispatchReceiverType ?: dispatchReceiverTypeForSubstitutedMembers,
|
||||
origin,
|
||||
newReceiverType,
|
||||
newContextReceiverTypes,
|
||||
newReturnType,
|
||||
@@ -208,7 +211,7 @@ class FirClassSubstitutionScope(
|
||||
session,
|
||||
constructor,
|
||||
derivedClassLookupTag,
|
||||
FirDeclarationOrigin.SubstitutionOverride,
|
||||
origin,
|
||||
newDispatchReceiverType,
|
||||
// Constructors' return types are expected to be non-flexible (i.e., non raw)
|
||||
newReturnType?.lowerBoundIfFlexible(),
|
||||
@@ -249,6 +252,7 @@ class FirClassSubstitutionScope(
|
||||
member,
|
||||
derivedClassLookupTag = derivedClassLookupTag,
|
||||
newDispatchReceiverType ?: dispatchReceiverTypeForSubstitutedMembers,
|
||||
origin,
|
||||
isExpect = makeExpect,
|
||||
)
|
||||
}
|
||||
@@ -262,6 +266,7 @@ class FirClassSubstitutionScope(
|
||||
member,
|
||||
derivedClassLookupTag,
|
||||
newDispatchReceiverType ?: dispatchReceiverTypeForSubstitutedMembers,
|
||||
origin,
|
||||
newReceiverType,
|
||||
newContextReceiverTypes,
|
||||
newReturnType,
|
||||
@@ -289,6 +294,7 @@ class FirClassSubstitutionScope(
|
||||
member as FirTypeParameterRefsOwner,
|
||||
symbolForOverride,
|
||||
substitutor,
|
||||
origin,
|
||||
forceTypeParametersRecreation = dispatchReceiverTypeForSubstitutedMembers.lookupTag != memberOwnerClassLookupTag
|
||||
)
|
||||
|
||||
@@ -320,7 +326,7 @@ class FirClassSubstitutionScope(
|
||||
// TODO: do we have fields with implicit type?
|
||||
val newReturnType = returnType?.substitute() ?: return original
|
||||
|
||||
return FirFakeOverrideGenerator.createSubstitutionOverrideField(session, member, derivedClassLookupTag, newReturnType)
|
||||
return FirFakeOverrideGenerator.createSubstitutionOverrideField(session, member, derivedClassLookupTag, newReturnType, origin)
|
||||
}
|
||||
|
||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||
|
||||
+22
-13
@@ -37,6 +37,7 @@ object FirFakeOverrideGenerator {
|
||||
baseFunction: FirSimpleFunction,
|
||||
derivedClassLookupTag: ConeClassLikeLookupTag?,
|
||||
newDispatchReceiverType: ConeSimpleKotlinType?,
|
||||
origin: FirDeclarationOrigin.SubstitutionOverride,
|
||||
newReceiverType: ConeKotlinType? = null,
|
||||
newContextReceiverTypes: List<ConeKotlinType?>? = null,
|
||||
newReturnType: ConeKotlinType? = null,
|
||||
@@ -47,7 +48,7 @@ object FirFakeOverrideGenerator {
|
||||
): FirNamedFunctionSymbol {
|
||||
createSubstitutionOverrideFunction(
|
||||
symbolForSubstitutionOverride, session, baseFunction, derivedClassLookupTag, newDispatchReceiverType, newReceiverType,
|
||||
newContextReceiverTypes, newReturnType, newParameterTypes, newTypeParameters, isExpect, fakeOverrideSubstitution
|
||||
newContextReceiverTypes, newReturnType, newParameterTypes, newTypeParameters, isExpect, fakeOverrideSubstitution, origin,
|
||||
)
|
||||
return symbolForSubstitutionOverride
|
||||
}
|
||||
@@ -73,6 +74,7 @@ object FirFakeOverrideGenerator {
|
||||
newTypeParameters: List<FirTypeParameter>?,
|
||||
isExpect: Boolean = baseFunction.isExpect,
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution?,
|
||||
origin: FirDeclarationOrigin.SubstitutionOverride,
|
||||
): FirSimpleFunction {
|
||||
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
||||
// As second alternative, we can invent some light-weight kind of FirRegularClass
|
||||
@@ -81,7 +83,7 @@ object FirFakeOverrideGenerator {
|
||||
baseFunction,
|
||||
derivedClassLookupTag = derivedClassLookupTag,
|
||||
session,
|
||||
FirDeclarationOrigin.SubstitutionOverride,
|
||||
origin,
|
||||
isExpect,
|
||||
newDispatchReceiverType,
|
||||
newParameterTypes,
|
||||
@@ -210,13 +212,14 @@ object FirFakeOverrideGenerator {
|
||||
newReceiverType,
|
||||
newContextReceiverTypes,
|
||||
newReturnType,
|
||||
fakeOverrideSubstitution
|
||||
fakeOverrideSubstitution,
|
||||
origin,
|
||||
)
|
||||
emptyList()
|
||||
}
|
||||
newTypeParameters == null -> {
|
||||
val (copiedTypeParameters, substitutor) = createNewTypeParametersAndSubstitutor(
|
||||
useSiteSession, baseFunction, symbolForOverride, ConeSubstitutor.Empty
|
||||
useSiteSession, baseFunction, symbolForOverride, ConeSubstitutor.Empty, origin
|
||||
)
|
||||
val copiedParameterTypes = baseFunction.valueParameters.map {
|
||||
substitutor.substituteOrNull(it.returnTypeRef.coneType)
|
||||
@@ -236,7 +239,8 @@ object FirFakeOverrideGenerator {
|
||||
copiedReceiverType,
|
||||
copiedContextReceiverTypes,
|
||||
copiedReturnType,
|
||||
newFakeOverrideSubstitution
|
||||
newFakeOverrideSubstitution,
|
||||
origin,
|
||||
)
|
||||
copiedTypeParameters
|
||||
}
|
||||
@@ -248,7 +252,8 @@ object FirFakeOverrideGenerator {
|
||||
newReceiverType,
|
||||
newContextReceiverTypes,
|
||||
newReturnType,
|
||||
fakeOverrideSubstitution
|
||||
fakeOverrideSubstitution,
|
||||
origin,
|
||||
)
|
||||
newTypeParameters
|
||||
}
|
||||
@@ -263,6 +268,7 @@ object FirFakeOverrideGenerator {
|
||||
newContextReceiverTypes: List<ConeKotlinType?>?,
|
||||
newReturnType: ConeKotlinType?,
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution?,
|
||||
origin: FirDeclarationOrigin,
|
||||
) {
|
||||
annotations += baseFunction.annotations
|
||||
|
||||
@@ -289,7 +295,7 @@ object FirFakeOverrideGenerator {
|
||||
newParameterTypes ?: List(baseFunction.valueParameters.size) { null }
|
||||
) { valueParameter, newType ->
|
||||
buildValueParameterCopy(valueParameter) {
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride
|
||||
this.origin = origin
|
||||
returnTypeRef = valueParameter.returnTypeRef.withReplacedConeType(newType)
|
||||
symbol = FirValueParameterSymbol(valueParameter.name)
|
||||
containingFunctionSymbol = fakeFunctionSymbol
|
||||
@@ -313,6 +319,7 @@ object FirFakeOverrideGenerator {
|
||||
baseProperty: FirProperty,
|
||||
derivedClassLookupTag: ConeClassLikeLookupTag,
|
||||
newDispatchReceiverType: ConeSimpleKotlinType?,
|
||||
origin: FirDeclarationOrigin.SubstitutionOverride,
|
||||
newReceiverType: ConeKotlinType? = null,
|
||||
newContextReceiverTypes: List<ConeKotlinType?>? = null,
|
||||
newReturnType: ConeKotlinType? = null,
|
||||
@@ -321,7 +328,7 @@ object FirFakeOverrideGenerator {
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution? = null
|
||||
): FirPropertySymbol {
|
||||
createCopyForFirProperty(
|
||||
symbolForSubstitutionOverride, baseProperty, derivedClassLookupTag, session, FirDeclarationOrigin.SubstitutionOverride,
|
||||
symbolForSubstitutionOverride, baseProperty, derivedClassLookupTag, session, origin,
|
||||
isExpect, newDispatchReceiverType, newTypeParameters, newReceiverType, newContextReceiverTypes, newReturnType,
|
||||
fakeOverrideSubstitution = fakeOverrideSubstitution
|
||||
).apply {
|
||||
@@ -481,7 +488,7 @@ object FirFakeOverrideGenerator {
|
||||
}.also { accessor ->
|
||||
when (accessor.origin) {
|
||||
FirDeclarationOrigin.IntersectionOverride -> accessor.originalForIntersectionOverrideAttr = this
|
||||
FirDeclarationOrigin.SubstitutionOverride -> accessor.originalForSubstitutionOverrideAttr = this
|
||||
is FirDeclarationOrigin.SubstitutionOverride -> accessor.originalForSubstitutionOverrideAttr = this
|
||||
else -> {}
|
||||
}
|
||||
|
||||
@@ -544,7 +551,7 @@ object FirFakeOverrideGenerator {
|
||||
}
|
||||
newTypeParameters == null -> {
|
||||
val (copiedTypeParameters, substitutor) = createNewTypeParametersAndSubstitutor(
|
||||
useSiteSession, baseProperty, symbol, ConeSubstitutor.Empty
|
||||
useSiteSession, baseProperty, symbol, ConeSubstitutor.Empty, origin,
|
||||
)
|
||||
val (copiedReceiverType, copiedContextReceiverTypes, possibleReturnType) = substituteReceiverAndReturnType(
|
||||
baseProperty, newReceiverType, newContextReceiverTypes, newReturnType, substitutor
|
||||
@@ -642,13 +649,14 @@ object FirFakeOverrideGenerator {
|
||||
session: FirSession,
|
||||
baseField: FirField,
|
||||
derivedClassLookupTag: ConeClassLikeLookupTag,
|
||||
newReturnType: ConeKotlinType?
|
||||
newReturnType: ConeKotlinType?,
|
||||
origin: FirDeclarationOrigin.SubstitutionOverride,
|
||||
): FirFieldSymbol {
|
||||
val symbol = FirFieldSymbol(CallableId(derivedClassLookupTag.classId, baseField.name))
|
||||
buildField {
|
||||
moduleData = session.nullableModuleData ?: baseField.moduleData
|
||||
this.symbol = symbol
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride
|
||||
this.origin = origin
|
||||
returnTypeRef = baseField.returnTypeRef.withReplacedConeType(newReturnType)
|
||||
|
||||
source = baseField.source
|
||||
@@ -673,6 +681,7 @@ object FirFakeOverrideGenerator {
|
||||
member: FirTypeParameterRefsOwner,
|
||||
symbolForOverride: FirBasedSymbol<*>,
|
||||
substitutor: ConeSubstitutor,
|
||||
origin: FirDeclarationOrigin,
|
||||
forceTypeParametersRecreation: Boolean = true
|
||||
): Pair<List<FirTypeParameterRef>, ConeSubstitutor> {
|
||||
if (member.typeParameters.isEmpty()) return Pair(member.typeParameters, substitutor)
|
||||
@@ -681,7 +690,7 @@ object FirFakeOverrideGenerator {
|
||||
FirTypeParameterBuilder().apply {
|
||||
source = typeParameter.source
|
||||
moduleData = typeParameter.moduleData
|
||||
origin = FirDeclarationOrigin.SubstitutionOverride
|
||||
this.origin = origin
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
name = typeParameter.name
|
||||
symbol = FirTypeParameterSymbol()
|
||||
|
||||
@@ -563,7 +563,7 @@ fun FirFunction.getAsForbiddenNamedArgumentsTarget(
|
||||
FirDeclarationOrigin.ImportedFromObjectOrStatic ->
|
||||
importedFromObjectOrStaticData?.original?.getAsForbiddenNamedArgumentsTarget(session)
|
||||
|
||||
FirDeclarationOrigin.IntersectionOverride, FirDeclarationOrigin.SubstitutionOverride, FirDeclarationOrigin.Delegated -> {
|
||||
FirDeclarationOrigin.IntersectionOverride, is FirDeclarationOrigin.SubstitutionOverride, FirDeclarationOrigin.Delegated -> {
|
||||
var result: ForbiddenNamedArgumentsTarget? =
|
||||
unwrapFakeOverridesOrDelegated().getAsForbiddenNamedArgumentsTarget(session) ?: return null
|
||||
originScope?.processOverriddenFunctions(symbol as FirNamedFunctionSymbol) {
|
||||
|
||||
@@ -27,7 +27,11 @@ sealed class FirDeclarationOrigin(
|
||||
object SamConstructor : FirDeclarationOrigin()
|
||||
object Enhancement : FirDeclarationOrigin()
|
||||
object ImportedFromObjectOrStatic : FirDeclarationOrigin()
|
||||
object SubstitutionOverride : FirDeclarationOrigin(fromSupertypes = true)
|
||||
sealed class SubstitutionOverride(displayName: String) : FirDeclarationOrigin(displayName, fromSupertypes = true) {
|
||||
object DeclarationSite : SubstitutionOverride("SubstitutionOverride(DeclarationSite)")
|
||||
object CallSite : SubstitutionOverride("SubstitutionOverride(CallSite)")
|
||||
}
|
||||
|
||||
object IntersectionOverride : FirDeclarationOrigin(fromSupertypes = true)
|
||||
object Delegated : FirDeclarationOrigin()
|
||||
object RenamedForOverride : FirDeclarationOrigin()
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ val FirProperty.hasBackingField: Boolean
|
||||
if (symbol is FirSyntheticPropertySymbol) return false
|
||||
if (isStatic) return false // For Enum.entries
|
||||
when (origin) {
|
||||
FirDeclarationOrigin.SubstitutionOverride -> return false
|
||||
is FirDeclarationOrigin.SubstitutionOverride -> return false
|
||||
FirDeclarationOrigin.IntersectionOverride -> return false
|
||||
FirDeclarationOrigin.Delegated -> return false
|
||||
else -> {
|
||||
|
||||
Reference in New Issue
Block a user