[Analysis API] fix common code resolution which requires FirSyntheticPropertiesStorage

Added test `FirSourceLazyDeclarationResolveTestGenerated.Classes.testClassDelegatedInCommonCode`
now fails with another exception (KT-62772). It's fixed in the following commit.

^KT-62768 fixed
This commit is contained in:
Ilya Kirillov
2023-10-20 12:29:01 +02:00
committed by Space Team
parent 0325ffaa01
commit 80fda25c58
5 changed files with 234 additions and 10 deletions
@@ -32,12 +32,13 @@ import org.jetbrains.kotlin.fir.session.DefaultCallConflictResolverFactory
import org.jetbrains.kotlin.platform.has
import org.jetbrains.kotlin.platform.jvm.JvmPlatform
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.fir.session.FirSessionFactoryHelper.registerDefaultComponents
@OptIn(SessionConfiguration::class)
internal class LLFirCommonSessionFactory(project: Project) : LLFirAbstractSessionFactory(project) {
override fun createSourcesSession(module: KtSourceModule): LLFirSourcesSession {
return doCreateSourcesSession(module) { context ->
registerModuleIndependentCommonComponents()
registerDefaultComponents()
register(
FirSymbolProvider::class,
@@ -56,7 +57,7 @@ internal class LLFirCommonSessionFactory(project: Project) : LLFirAbstractSessio
override fun createLibrarySession(module: KtModule): LLFirLibraryOrLibrarySourceResolvableModuleSession {
return doCreateLibrarySession(module) { context ->
registerModuleIndependentCommonComponents()
registerDefaultComponents()
register(
FirSymbolProvider::class,
@@ -75,7 +76,7 @@ internal class LLFirCommonSessionFactory(project: Project) : LLFirAbstractSessio
override fun createBinaryLibrarySession(module: KtBinaryModule): LLFirLibrarySession {
return doCreateBinaryLibrarySession(module) {
registerModuleIndependentCommonComponents()
registerDefaultComponents()
registerPlatformSpecificComponentsIfAny(module)
}
}
@@ -108,13 +109,6 @@ internal class LLFirCommonSessionFactory(project: Project) : LLFirAbstractSessio
}
}
private fun LLFirSession.registerModuleIndependentCommonComponents() {
register(FirVisibilityChecker::class, FirVisibilityChecker.Default)
register(ConeCallConflictResolverFactory::class, DefaultCallConflictResolverFactory)
register(FirPlatformClassMapper::class, FirPlatformClassMapper.Default)
register(FirOverridesBackwardCompatibilityHelper::class, FirJvmOverridesBackwardCompatibilityHelper)
}
private fun LLFirSession.registerPlatformSpecificComponentsIfAny(module: KtModule) {
if (module.platform.has<JvmPlatform>())
register(FirJvmTypeMapper::class, FirJvmTypeMapper(this))
@@ -0,0 +1,9 @@
// TARGET_PLATFORM: Common
public class A<caret>A(
private val content: Map<String, Int>
) : Map<String, Int> by content {
override fun toString(): String {
return content.entries.toString()
}
}
@@ -0,0 +1,209 @@
RAW_FIR:
FILE: [ResolvedTo(RAW_FIR)] classDelegatedInCommonCode.kt
public final? [ResolvedTo(RAW_FIR)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : Map<String, Int> {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<String, Int> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
IMPORTS:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final? [ResolvedTo(RAW_FIR)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : Map<String, Int> {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<String, Int> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
COMPILER_REQUIRED_ANNOTATIONS:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : Map<String, Int> {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<String, Int> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
COMPANION_GENERATION:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final? [ResolvedTo(COMPANION_GENERATION)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : Map<String, Int> {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<String, Int> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
SUPER_TYPES:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final? [ResolvedTo(SUPER_TYPES)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
TYPES:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final? [ResolvedTo(TYPES)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
STATUS:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final [ResolvedTo(STATUS)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
EXPECT_ACTUAL_MATCHING:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final [ResolvedTo(EXPECT_ACTUAL_MATCHING)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
CONTRACTS:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final [ResolvedTo(CONTRACTS)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
ANNOTATION_ARGUMENTS:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final [ResolvedTo(ANNOTATION_ARGUMENTS)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/AA.content] content: Map<String, Int>): R|AA| {
LAZY_super<<implicit>>
}
private final [ResolvedTo(RAW_FIR)] field $$delegate_0: Map<R|kotlin/String|, R|kotlin/Int|> = LAZY_EXPRESSION
private final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val content: Map<String, Int> = R|<local>/content|
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=AA] get(): Map<String, Int>
public? open? override [ResolvedTo(RAW_FIR)] fun toString(): String { LAZY_BLOCK }
}
BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] classDelegatedInCommonCode.kt
public final [ResolvedTo(BODY_RESOLVE)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=AA] constructor([ResolvedTo(BODY_RESOLVE)] [CorrespondingProperty=/AA.content] content: R|kotlin/collections/Map<kotlin/String, kotlin/Int>|): R|AA| {
super<R|kotlin/Any|>()
}
private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|<local>/content|
private final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val content: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|<local>/content|
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=AA] get(): R|kotlin/collections/Map<kotlin/String, kotlin/Int>|
public open override [ResolvedTo(STATUS)] fun toString(): R|kotlin/String| { LAZY_BLOCK }
}
FILE RAW TO BODY:
FILE: [ResolvedTo(BODY_RESOLVE)] classDelegatedInCommonCode.kt
public final [ResolvedTo(BODY_RESOLVE)] [DelegateFieldsMapKey={0=FirFieldSymbol /AA.$$delegate_0}] class AA : R|kotlin/collections/Map<kotlin/String, kotlin/Int>| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=AA] constructor([ResolvedTo(BODY_RESOLVE)] [CorrespondingProperty=/AA.content] content: R|kotlin/collections/Map<kotlin/String, kotlin/Int>|): R|AA| {
super<R|kotlin/Any|>()
}
private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|<local>/content|
private final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val content: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|<local>/content|
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=AA] get(): R|kotlin/collections/Map<kotlin/String, kotlin/Int>|
public open override [ResolvedTo(BODY_RESOLVE)] fun toString(): R|kotlin/String| {
^toString this@R|/AA|.R|/AA.content|.R|SubstitutionOverride<kotlin/collections/Map.entries: R|kotlin/collections/Set<kotlin/collections/Map.Entry<kotlin/String, kotlin/Int>>|>|.R|kotlin/Any.toString|()
}
}
@@ -645,6 +645,12 @@ public class FirOutOfContentRootLazyDeclarationResolveTestGenerated extends Abst
runTest("analysis/low-level-api-fir/testData/lazyResolve/classes/annotationWithTarget.kt");
}
@Test
@TestMetadata("classDelegatedInCommonCode.kt")
public void testClassDelegatedInCommonCode() throws Exception {
runTest("analysis/low-level-api-fir/testData/lazyResolve/classes/classDelegatedInCommonCode.kt");
}
@Test
@TestMetadata("classWithTypeParameters.kt")
public void testClassWithTypeParameters() throws Exception {
@@ -645,6 +645,12 @@ public class FirSourceLazyDeclarationResolveTestGenerated extends AbstractFirSou
runTest("analysis/low-level-api-fir/testData/lazyResolve/classes/annotationWithTarget.kt");
}
@Test
@TestMetadata("classDelegatedInCommonCode.kt")
public void testClassDelegatedInCommonCode() throws Exception {
runTest("analysis/low-level-api-fir/testData/lazyResolve/classes/classDelegatedInCommonCode.kt");
}
@Test
@TestMetadata("classWithTypeParameters.kt")
public void testClassWithTypeParameters() throws Exception {