FIR IDE/LC: introduce/use delegated member scope

This commit is contained in:
Jinseong Jeon
2021-10-20 16:20:14 -07:00
committed by Ilya Kirillov
parent 700f8ac287
commit 3f2c86afb8
18 changed files with 271 additions and 20 deletions
@@ -19,11 +19,17 @@ import org.jetbrains.kotlin.psi.KtFile
public abstract class KtScopeProvider : KtAnalysisSessionComponent() {
public abstract fun getMemberScope(classSymbol: KtSymbolWithMembers): KtMemberScope
public abstract fun getStaticMemberScope(symbol: KtSymbolWithMembers): KtScope
public abstract fun getDeclaredMemberScope(classSymbol: KtSymbolWithMembers): KtDeclaredMemberScope
public abstract fun getDelegatedMemberScope(classSymbol: KtSymbolWithMembers): KtDelegatedMemberScope
public abstract fun getStaticMemberScope(symbol: KtSymbolWithMembers): KtScope
public abstract fun getFileScope(fileSymbol: KtFileSymbol): KtDeclarationScope<KtSymbolWithDeclarations>
public abstract fun getPackageScope(packageSymbol: KtPackageSymbol): KtPackageScope
public abstract fun getCompositeScope(subScopes: List<KtScope>): KtCompositeScope
public abstract fun getTypeScope(type: KtType): KtScope?
@@ -41,6 +47,9 @@ public interface KtScopeProviderMixIn : KtAnalysisSessionMixIn {
public fun KtSymbolWithMembers.getDeclaredMemberScope(): KtDeclaredMemberScope =
analysisSession.scopeProvider.getDeclaredMemberScope(this)
public fun KtSymbolWithMembers.getDelegatedMemberScope(): KtDelegatedMemberScope =
analysisSession.scopeProvider.getDelegatedMemberScope(this)
public fun KtSymbolWithMembers.getStaticMemberScope(): KtScope =
analysisSession.scopeProvider.getStaticMemberScope(this)
@@ -86,6 +86,10 @@ public interface KtDeclaredMemberScope : KtDeclarationScope<KtSymbolWithMembers>
override val owner: KtSymbolWithMembers
}
public interface KtDelegatedMemberScope : KtDeclarationScope<KtSymbolWithMembers> {
override val owner: KtSymbolWithMembers
}
public interface KtDeclarationScope<out T : KtSymbolWithDeclarations> : KtScope {
public val owner: T
}
@@ -100,4 +104,4 @@ public interface KtPackageScope : KtScope {
}
override fun getConstructors(): Sequence<KtConstructorSymbol> = withValidityAssertion { emptySequence() }
}
}
@@ -0,0 +1,12 @@
// DO_NOT_CHECK_SYMBOL_RESTORE
interface I {
fun foo()
}
class A(
private val p: I
) : I by p
// class: A
@@ -0,0 +1,24 @@
KtFunctionSymbol:
annotatedType: [] kotlin/Unit
annotationClassIds: []
annotations: []
callableIdIfNonLocal: /I.foo
dispatchType: A
hasStableParameterNames: true
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: OPEN
name: foo
origin: DELEGATED
receiverType: null
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
deprecationStatus: null
@@ -0,0 +1,27 @@
// DO_NOT_CHECK_SYMBOL_RESTORE
interface I1 {
fun foo()
}
class I1Impl: I1 {
override fun foo() {}
}
interface I2 {
fun bar()
fun baz()
}
class I2Impl: I2 {
override fun bar() {}
override fun baz() {}
}
open class A : I1 by I1Impl()
class B : I2 by I2Impl(), A() {
override fun baz() {}
}
// class: B
@@ -0,0 +1,24 @@
KtFunctionSymbol:
annotatedType: [] kotlin/Unit
annotationClassIds: []
annotations: []
callableIdIfNonLocal: /I2.bar
dispatchType: B
hasStableParameterNames: true
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: OPEN
name: bar
origin: DELEGATED
receiverType: null
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
deprecationStatus: null