[FIR] Fix case with lazy resolve in expect-actual annotation checker

Unresolved annotation arguments were treated as absent arguments,
which lead to false-positive reports.
Add assert and test for that and fix.

MR: KT-MR-12245

^KT-60671 Fixed
This commit is contained in:
Roman Efremov
2023-09-20 11:09:51 +02:00
committed by Space Team
parent 4c75fb108f
commit 0fd700de21
10 changed files with 106 additions and 13 deletions
@@ -232,7 +232,10 @@ object AbstractExpectActualAnnotationMatchChecker {
var firstIncompatibility: Incompatibility? = null
checkAnnotationsOnTypeRefAndArguments(expectTypeRef, actualTypeRef) { expectAnnotations, actualAnnotations, actualTypeRefSource ->
checkAnnotationsOnTypeRefAndArguments(
expectDeclarationSymbol, actualDeclarationSymbol,
expectTypeRef, actualTypeRef
) { expectAnnotations, actualAnnotations, actualTypeRefSource ->
if (firstIncompatibility == null) {
firstIncompatibility = areAnnotationListsCompatible(expectAnnotations, actualAnnotations, actualDeclarationSymbol)
?.let { Incompatibility(expectDeclarationSymbol, actualDeclarationSymbol, actualTypeRefSource, type = it) }
@@ -248,6 +248,10 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
* **Example**: for type `@Ann1 List<@Ann2 Map<@Ann3 Int, @Ann4 String>>`, there are 4 types to check in [checker].
*/
fun checkAnnotationsOnTypeRefAndArguments(
expectTypeRef: TypeRefMarker, actualTypeRef: TypeRefMarker, checker: AnnotationsCheckerCallback,
expectContainingSymbol: DeclarationSymbolMarker,
actualContainingSymbol: DeclarationSymbolMarker,
expectTypeRef: TypeRefMarker,
actualTypeRef: TypeRefMarker,
checker: AnnotationsCheckerCallback,
)
}