Skip to content

Commit

Permalink
FIR: Drop PossiblyFirFakeOverrideSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
dzharkov committed Nov 6, 2020
1 parent 7b48625 commit 2e4c41c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.fir.originalForSubstitutionOverride
import org.jetbrains.kotlin.fir.scopes.*
import org.jetbrains.kotlin.fir.scopes.impl.delegatedWrapperData
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import org.jetbrains.kotlin.fir.symbols.PossiblyFirFakeOverrideSymbol
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
import org.jetbrains.kotlin.ir.declarations.*
Expand Down Expand Up @@ -85,12 +84,12 @@ internal class DelegatedMemberGenerator(
}
}

private inline fun <reified S, reified D : FirCallableMemberDeclaration<D>> S.unwrapDelegateTarget(
private inline fun <reified S : FirCallableSymbol<D>, reified D : FirCallableMemberDeclaration<D>> S.unwrapDelegateTarget(
subClassLookupTag: ConeClassLikeLookupTag,
noinline directOverridden: S.() -> List<S>,
firField: FirField,
firSubClass: FirClass<*>,
): D? where S : FirCallableSymbol<D>, S : PossiblyFirFakeOverrideSymbol<D, S> {
): D? {
val unwrappedIntersectionSymbol =
this.unwrapIntersectionOverride(directOverridden) ?: return null

Expand All @@ -117,7 +116,6 @@ internal class DelegatedMemberGenerator(
}

private fun <S : FirCallableSymbol<*>> S.unwrapIntersectionOverride(directOverridden: S.() -> List<S>): S? {
if (this !is PossiblyFirFakeOverrideSymbol<*, *>) return this
if (this.fir.isIntersectionOverride) return directOverridden().firstOrNull { it.fir.delegatedWrapperData != null }
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import org.jetbrains.kotlin.fir.symbols.PossiblyFirFakeOverrideSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
Expand Down Expand Up @@ -130,7 +129,7 @@ class FakeOverrideGenerator(
return result
}

private inline fun <reified D : FirCallableMemberDeclaration<D>, reified S, reified I : IrDeclaration> createFakeOverriddenIfNeeded(
private inline fun <reified D : FirCallableMemberDeclaration<D>, reified S : FirCallableSymbol<D>, reified I : IrDeclaration> createFakeOverriddenIfNeeded(
klass: FirClass<*>,
irClass: IrClass,
isLocal: Boolean,
Expand All @@ -144,7 +143,7 @@ class FakeOverrideGenerator(
realDeclarationSymbols: Set<AbstractFirBasedSymbol<*>>,
computeDirectOverridden: FirTypeScope.(S) -> List<S>,
scope: FirTypeScope,
) where S : FirCallableSymbol<D>, S : PossiblyFirFakeOverrideSymbol<D, S> {
) {
if (originalSymbol !is S || originalSymbol in realDeclarationSymbols) return
val classLookupTag = klass.symbol.toLookupTag()
val originalDeclaration = originalSymbol.fir
Expand Down Expand Up @@ -189,7 +188,7 @@ class FakeOverrideGenerator(
}
}

private inline fun <S : FirCallableSymbol<*>> computeBaseSymbols(
private inline fun <reified S : FirCallableSymbol<*>> computeBaseSymbols(
symbol: S,
basedSymbol: S,
directOverridden: FirTypeScope.(S) -> List<S>,
Expand All @@ -199,7 +198,7 @@ class FakeOverrideGenerator(
if (symbol.fir.origin != FirDeclarationOrigin.IntersectionOverride) return listOf(basedSymbol)
return scope.directOverridden(symbol).map {
@Suppress("UNCHECKED_CAST")
if (it is PossiblyFirFakeOverrideSymbol<*, *> && it.fir.isSubstitutionOverride && it.dispatchReceiverClassOrNull() == containingClass)
if (it.fir.isSubstitutionOverride && it.dispatchReceiverClassOrNull() == containingClass)
it.originalForSubstitutionOverride!!
else
it
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.symbols.impl
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.symbols.AccessorSymbol
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.PossiblyFirFakeOverrideSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
Expand All @@ -24,7 +23,7 @@ sealed class FirFunctionSymbol<D : FirFunction<D>>(

open class FirNamedFunctionSymbol(
callableId: CallableId,
) : FirFunctionSymbol<FirSimpleFunction>(callableId), PossiblyFirFakeOverrideSymbol<FirSimpleFunction, FirNamedFunctionSymbol>
) : FirFunctionSymbol<FirSimpleFunction>(callableId)

class FirConstructorSymbol(
callableId: CallableId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.declarations.FirVariable
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.PossiblyFirFakeOverrideSymbol
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name

Expand All @@ -23,7 +22,7 @@ open class FirVariableSymbol<D : FirVariable<D>>(override val callableId: Callab

open class FirPropertySymbol(
callableId: CallableId,
) : FirVariableSymbol<FirProperty>(callableId), PossiblyFirFakeOverrideSymbol<FirProperty, FirPropertySymbol> {
) : FirVariableSymbol<FirProperty>(callableId) {
// TODO: should we use this constructor for local variables?
constructor(name: Name) : this(CallableId(name))
}
Expand Down

0 comments on commit 2e4c41c

Please sign in to comment.