[AA] getExpectForActual analysis-api now returns compatible or weakly incompatible
^KTIJ-27522 Fixed It's the only reasonable behavior for this API in it's current shape (when it returns a list of declarations) It's a common mistake to take only Compatible from expectActualMatchingMap. The problem will be gone after I fix KT-62590 Motivation to fix this bug, is because it will be easier for me to split expect-actual matcher-checker-monster thing KT-62590 Review: https://jetbrains.team/p/kt/reviews/12750/timeline
This commit is contained in:
+6
-7
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasActualModifier
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.K1ExpectActualCompatibility
|
||||
import org.jetbrains.kotlin.resolve.multiplatform.isCompatibleOrWeaklyIncompatible
|
||||
|
||||
internal class KtFe10MultiplatformInfoProvider(
|
||||
override val analysisSession: KtFe10AnalysisSession,
|
||||
@@ -25,11 +25,10 @@ internal class KtFe10MultiplatformInfoProvider(
|
||||
if (actual.psiSafe<KtDeclaration>()?.hasActualModifier() != true) return emptyList()
|
||||
val memberDescriptor = (getSymbolDescriptor(actual) as? MemberDescriptor)?.takeIf { it.isActual } ?: return emptyList()
|
||||
|
||||
val expectedCompatibilityMap =
|
||||
ExpectedActualResolver.findExpectedForActual(memberDescriptor) ?: return emptyList()
|
||||
|
||||
val expectsForActual = (expectedCompatibilityMap[K1ExpectActualCompatibility.Compatible]
|
||||
?: expectedCompatibilityMap.values.flatten())
|
||||
return expectsForActual.map { it.toKtSymbol(analysisContext) as KtDeclarationSymbol }
|
||||
return ExpectedActualResolver.findExpectedForActual(memberDescriptor).orEmpty().asSequence()
|
||||
.filter { it.key.isCompatibleOrWeaklyIncompatible }
|
||||
.flatMap { it.value }
|
||||
.map { it.toKtSymbol(analysisContext) as KtDeclarationSymbol }
|
||||
.toList()
|
||||
}
|
||||
}
|
||||
+6
@@ -52,6 +52,12 @@ public class Fe10IdeNormalAnalysisSourceModuleExpectForActualTestGenerated exten
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/multiplatformInfoProvider/expectForActual"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("matchingButIncompatibleExpect.kt")
|
||||
public void testMatchingButIncompatibleExpect() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/multiplatformInfoProvider/expectForActual/matchingButIncompatibleExpect.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleExpects.kt")
|
||||
public void testMultipleExpects() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user