[Analysis API] Add KtReceiverParameterSymbol#correspondingSymbol

This commit is contained in:
Stanislav Erokhin
2022-06-22 18:26:00 +02:00
committed by teamcity
parent dfcf2cfa84
commit 66851c7afd
13 changed files with 25 additions and 3 deletions
@@ -7,12 +7,14 @@ package org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased
import org.jetbrains.kotlin.analysis.api.descriptors.Fe10AnalysisContext
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.KtFe10DescSymbol
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.toKtSymbol
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.toKtType
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtReceiverParameterSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
class KtFe10ReceiverParameterSymbol(
@@ -25,6 +27,9 @@ class KtFe10ReceiverParameterSymbol(
override val descriptor: ReceiverParameterDescriptor
get() = withValidityAssertion { _descriptor }
override val owningCallableSymbol: KtCallableSymbol
get() = withValidityAssertion { _descriptor.containingDeclaration.toKtSymbol(analysisContext) as KtCallableSymbol }
override fun createPointer(): KtSymbolPointer<KtSymbol> = withValidityAssertion {
TODO("Not yet implemented")
}
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSession
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
@@ -36,6 +37,8 @@ internal class KtFirReceiverParameterSymbol(
?: error("$firSymbol doesn't have an extension receiver.")
}
override val owningCallableSymbol: KtCallableSymbol by cached { builder.callableBuilder.buildCallableSymbol(firSymbol) }
override val origin: KtSymbolOrigin = withValidityAssertion { firSymbol.fir.ktSymbolOrigin() }
override fun createPointer(): KtSymbolPointer<KtFirReceiverParameterSymbol> = withValidityAssertion {
@@ -5,10 +5,8 @@
package org.jetbrains.kotlin.analysis.api.symbols
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtAnnotatedSymbol
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtPossibleMemberSymbol
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithKind
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithTypeParameters
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.name.CallableId
@@ -29,4 +27,10 @@ public sealed class KtCallableSymbol : KtSymbolWithKind, KtPossibleMemberSymbol,
*/
public abstract class KtReceiverParameterSymbol : KtSymbol {
public abstract val type: KtType
/**
* Link to the corresponding function or property.
* In terms of the example above -- this is link to the function foo.
*/
public abstract val owningCallableSymbol: KtCallableSymbol
}
@@ -5,6 +5,7 @@ KtSuccessCallInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtAnonymousFunctionSymbol(<local>/<no name provided>)
type: test/Target<kotlin/String>
type = test.Target<kotlin.String>
extensionReceiver = null
@@ -5,6 +5,7 @@ KtSuccessCallInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtAnonymousFunctionSymbol(<local>/<no name provided>)
type: test/Target<kotlin/String>
type = test.Target<kotlin.String>
extensionReceiver = null
@@ -4,6 +4,7 @@ KtSuccessCallInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/call)
type: JavaClass
type = JavaClass
extensionReceiver = null
@@ -4,6 +4,7 @@ KtSuccessCallInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/call)
type: JavaClass
type = JavaClass
extensionReceiver = null
@@ -4,6 +4,7 @@ KtSuccessCallInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/foo)
type: A
type = A
extensionReceiver = null
@@ -4,6 +4,7 @@ KtSuccessCallInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/foo)
type: A
type = A
extensionReceiver = null
@@ -5,6 +5,7 @@ KtSuccessCallInfo:
original = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/test)
type: kotlin/Any
type = kotlin.Any
type = kotlin.String
@@ -7,6 +7,7 @@ KtSuccessCallInfo:
original = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtFunctionSymbol(/test)
type: kotlin/Any
type = kotlin.Any
type = kotlin.String
@@ -5,6 +5,7 @@ KtApplicableCallCandidateInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtAnonymousFunctionSymbol(<local>/<no name provided>)
type: test/Target<kotlin/String>
type = test.Target<kotlin.String>
extensionReceiver = null
@@ -5,6 +5,7 @@ KtApplicableCallCandidateInfo:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
owningCallableSymbol: KtAnonymousFunctionSymbol(<local>/<no name provided>)
type: test/Target<kotlin/String>
type = test.Target<Stub (chain inference): TypeVariable(T)>
extensionReceiver = null