[FE1.0] Fix false reporting of non-matching annotations in IDE...
...when typealiased expect class used in class literal. ^KTIJ-26700 Fixed
This commit is contained in:
committed by
Space Team
parent
3124cbcbad
commit
6b217369a8
+6
@@ -1419,6 +1419,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
|||||||
public void testTypealiasedAnnotationAsArgument() throws Exception {
|
public void testTypealiasedAnnotationAsArgument() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAnnotationAsArgument.kt");
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAnnotationAsArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("typealiasedAsKClassArg.kt")
|
||||||
|
public void testTypealiasedAsKClassArg() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAsKClassArg.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -1419,6 +1419,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
|||||||
public void testTypealiasedAnnotationAsArgument() throws Exception {
|
public void testTypealiasedAnnotationAsArgument() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAnnotationAsArgument.kt");
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAnnotationAsArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("typealiasedAsKClassArg.kt")
|
||||||
|
public void testTypealiasedAsKClassArg() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAsKClassArg.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-7
@@ -389,13 +389,17 @@ class ClassicExpectActualMatchingContext(
|
|||||||
return classDescriptor
|
return classDescriptor
|
||||||
}
|
}
|
||||||
val classId = classDescriptor.classId
|
val classId = classDescriptor.classId
|
||||||
// For IDE composite module analysis, when actual annotation may differ
|
return findExpandedExpectClassInPlatformModule(classId) ?: classDescriptor
|
||||||
val platformDescriptor = platformModule.findClassifierAcrossModuleDependencies(classId)
|
}
|
||||||
return when (platformDescriptor) {
|
}
|
||||||
is ClassDescriptor -> platformDescriptor
|
|
||||||
is TypeAliasDescriptor -> platformDescriptor.classDescriptor ?: classDescriptor
|
// For IDE composite module analysis, when actual class may differ
|
||||||
else -> classDescriptor
|
internal fun findExpandedExpectClassInPlatformModule(originalClassId: ClassId): ClassDescriptor? {
|
||||||
}
|
val classifier = platformModule.findClassifierAcrossModuleDependencies(originalClassId)
|
||||||
|
return when (classifier) {
|
||||||
|
is TypeAliasDescriptor -> classifier.classDescriptor
|
||||||
|
is ClassDescriptor -> classifier
|
||||||
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -7,10 +7,10 @@ package org.jetbrains.kotlin.resolve.multiplatform
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualCollectionArgumentsCompatibilityCheckStrategy
|
import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualCollectionArgumentsCompatibilityCheckStrategy
|
||||||
import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualMatchingContext
|
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
import org.jetbrains.kotlin.resolve.constants.KClassValue
|
||||||
|
|
||||||
internal fun ExpectActualMatchingContext<*>.areExpressionConstValuesEqual(
|
internal fun ClassicExpectActualMatchingContext.areExpressionConstValuesEqual(
|
||||||
expectValue: Any?,
|
expectValue: Any?,
|
||||||
actualValue: Any?,
|
actualValue: Any?,
|
||||||
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
||||||
@@ -36,6 +36,16 @@ internal fun ExpectActualMatchingContext<*>.areExpressionConstValuesEqual(
|
|||||||
areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy)
|
areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
expectValue is KClassValue.Value.NormalClass && actualValue is KClassValue.Value.NormalClass -> {
|
||||||
|
val expectClassIdOriginal = expectValue.classId
|
||||||
|
val expectClassIdPlatform = findExpandedExpectClassInPlatformModule(expectClassIdOriginal)?.classId
|
||||||
|
val expectValueCopy = expectValue.copy(
|
||||||
|
value = expectValue.value.copy(
|
||||||
|
classId = expectClassIdPlatform ?: expectClassIdOriginal
|
||||||
|
)
|
||||||
|
)
|
||||||
|
expectValueCopy == actualValue
|
||||||
|
}
|
||||||
else -> expectValue == actualValue
|
else -> expectValue == actualValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// WITH_STDLIB
|
||||||
|
// MODULE: common
|
||||||
|
expect class Typealiased
|
||||||
|
|
||||||
|
annotation class Ann(val p: kotlin.reflect.KClass<*>)
|
||||||
|
|
||||||
|
@Ann(Typealiased::class)
|
||||||
|
expect fun test()
|
||||||
|
|
||||||
|
@Ann(Array<Typealiased>::class)
|
||||||
|
expect fun testInArray()
|
||||||
|
|
||||||
|
// MODULE: main()()(common)
|
||||||
|
class TypealiasedImpl
|
||||||
|
|
||||||
|
actual typealias Typealiased = TypealiasedImpl
|
||||||
|
|
||||||
|
@Ann(Typealiased::class)
|
||||||
|
actual fun test() {}
|
||||||
|
|
||||||
|
@Ann(Array<Typealiased>::class)
|
||||||
|
actual fun testInArray() {}
|
||||||
Generated
+6
@@ -24206,6 +24206,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
public void testTypealiasedAnnotationAsArgument() throws Exception {
|
public void testTypealiasedAnnotationAsArgument() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAnnotationAsArgument.kt");
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAnnotationAsArgument.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("typealiasedAsKClassArg.kt")
|
||||||
|
public void testTypealiasedAsKClassArg() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/hmpp/multiplatformCompositeAnalysis/annotationMatching/typealiasedAsKClassArg.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user