[AA] Add expectForActual

#KT-54864

Merge-request: KT-MR-8222
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
This commit is contained in:
Vladimir Dolzhenko
2023-01-13 21:36:04 +00:00
committed by Space Team
parent 3afb93ca31
commit ca31307941
16 changed files with 400 additions and 1 deletions
@@ -54,6 +54,7 @@ public abstract class KtAnalysisSession(final override val token: KtLifetimeToke
KtSymbolDeclarationRendererMixIn,
KtVisibilityCheckerMixIn,
KtMemberSymbolProviderMixin,
KtMultiplatformInfoProviderMixin,
KtInheritorsProviderMixIn,
KtTypeCreatorMixIn,
KtAnalysisScopeProviderMixIn,
@@ -136,6 +137,9 @@ public abstract class KtAnalysisSession(final override val token: KtLifetimeToke
internal val inheritorsProvider: KtInheritorsProvider get() = inheritorsProviderImpl
protected abstract val inheritorsProviderImpl: KtInheritorsProvider
internal val multiplatformInfoProvider: KtMultiplatformInfoProvider get() = multiplatformInfoProviderImpl
protected abstract val multiplatformInfoProviderImpl: KtMultiplatformInfoProvider
internal val symbolInfoProvider: KtSymbolInfoProvider get() = symbolInfoProviderImpl
protected abstract val symbolInfoProviderImpl: KtSymbolInfoProvider
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2023 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.analysis.api.components
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.analysis.api.symbols.KtDeclarationSymbol
public abstract class KtMultiplatformInfoProvider : KtAnalysisSessionComponent() {
public abstract fun getExpectForActual(actual: KtDeclarationSymbol): KtDeclarationSymbol?
}
public interface KtMultiplatformInfoProviderMixin : KtAnalysisSessionMixIn {
/**
* Gives expect symbol for the actual one if it is available.
**/
public fun KtDeclarationSymbol.getExpectForActual(): KtDeclarationSymbol? =
withValidityAssertion { analysisSession.multiplatformInfoProvider.getExpectForActual(this) }
}
@@ -10,6 +10,6 @@ import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithTypeParamet
/**
* Represents a symbol of declaration which can be directly expressed in source code.
* Eg, classes, type parameters or functions ar [KtDeclarationSymbol], but files and packages are not
* Eg, classes, type parameters or functions are [KtDeclarationSymbol], but files and packages are not
*/
public sealed interface KtDeclarationSymbol : KtSymbol, KtSymbolWithTypeParameters, KtAnnotatedSymbol
@@ -0,0 +1,16 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: commonMain
// FILE: Common.kt
package sample
expect object Platform {
val name: String
}
// MODULE: androidMain(commonMain)
// FILE: JvmAndroid.kt
package sample
actual object <caret>Platform {
actual val name: String = "JVM"
}
@@ -0,0 +1 @@
expected symbol: Common.kt : object Platform