FIR IDE: correctly set symbol origin for fake overridden ones

This commit is contained in:
Ilya Kirillov
2020-07-04 00:40:09 +03:00
parent 88548d988a
commit 1d92fbaa7f
9 changed files with 72 additions and 18 deletions
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.symbols
import org.jetbrains.kotlin.fir.FirSymbolOwner
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
interface PossiblyFirFakeOverrideSymbol<E, S : FirBasedSymbol<E>> : FirBasedSymbol<E> where E : FirSymbolOwner<E>, E : FirDeclaration {
// contract isFakeOverride == true <=> overriddenSymbol != null
val isFakeOverride: Boolean
val overriddenSymbol: S?
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -8,6 +8,7 @@ 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
@@ -23,10 +24,10 @@ sealed class FirFunctionSymbol<D : FirFunction<D>>(
open class FirNamedFunctionSymbol(
callableId: CallableId,
val isFakeOverride: Boolean = false,
override val isFakeOverride: Boolean = false,
// Actual for fake override only
override val overriddenSymbol: FirNamedFunctionSymbol? = null
) : FirFunctionSymbol<FirSimpleFunction>(callableId)
) : FirFunctionSymbol<FirSimpleFunction>(callableId), PossiblyFirFakeOverrideSymbol<FirSimpleFunction, FirNamedFunctionSymbol>
class FirConstructorSymbol(
callableId: CallableId,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -12,6 +12,7 @@ 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
@@ -22,10 +23,10 @@ open class FirVariableSymbol<D : FirVariable<D>>(override val callableId: Callab
open class FirPropertySymbol(
callableId: CallableId,
val isFakeOverride: Boolean = false,
override val isFakeOverride: Boolean = false,
// Actual for fake override only
override val overriddenSymbol: FirPropertySymbol? = null
) : FirVariableSymbol<FirProperty>(callableId) {
) : FirVariableSymbol<FirProperty>(callableId), PossiblyFirFakeOverrideSymbol<FirProperty, FirPropertySymbol> {
// TODO: should we use this constructor for local variables?
constructor(name: Name) : this(CallableId(name))
}