[Analysis API] fix "KotlinIllegalStateExceptionWithAttachments: expected as maximum one expect for the actual"
^KT-61597 fixed
This commit is contained in:
committed by
Space Team
parent
f39153b6e6
commit
56910b70a3
+4
-3
@@ -9,15 +9,16 @@ 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 abstract fun getExpectForActual(actual: KtDeclarationSymbol): List<KtDeclarationSymbol>
|
||||
}
|
||||
|
||||
public interface KtMultiplatformInfoProviderMixin : KtAnalysisSessionMixIn {
|
||||
|
||||
/**
|
||||
* Gives expect symbol for the actual one if it is available.
|
||||
*
|
||||
* @return a single expect declaration corresponds to the [KtDeclarationSymbol] on valid code or multiple expects in a case of erroneous code with multiple expects.
|
||||
**/
|
||||
public fun KtDeclarationSymbol.getExpectForActual(): KtDeclarationSymbol? =
|
||||
public fun KtDeclarationSymbol.getExpectsForActual(): List<KtDeclarationSymbol> =
|
||||
withValidityAssertion { analysisSession.multiplatformInfoProvider.getExpectForActual(this) }
|
||||
|
||||
}
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
expected symbol: null
|
||||
expected symbols:
|
||||
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
expected symbol: Common.kt : object Platform
|
||||
expected symbols:
|
||||
Common.kt : object Platform
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
expected symbols:
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
|
||||
// MODULE: commonMain1
|
||||
// FILE: Common1.kt
|
||||
|
||||
package sample
|
||||
expect fun foo()
|
||||
|
||||
// MODULE: commonMain2
|
||||
// FILE: Common2.kt
|
||||
|
||||
package sample
|
||||
expect fun foo()
|
||||
|
||||
// MODULE: androidMain(commonMain1, commonMain2)
|
||||
// FILE: JvmAndroid.kt
|
||||
|
||||
package sample
|
||||
actual fun f<caret>oo() {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expected symbols:
|
||||
Common1.kt : fun foo()
|
||||
Common2.kt : fun foo()
|
||||
Reference in New Issue
Block a user