AA: pass wildcard suppression hints on declarations

^KT-61734
This commit is contained in:
Jinseong Jeon
2024-02-22 21:48:47 -08:00
committed by teamcity
parent d089db5a45
commit 9c16c52564
4 changed files with 79 additions and 14 deletions
@@ -13,7 +13,9 @@ import org.jetbrains.kotlin.name.JvmStandardClassIds.JVM_SUPPRESS_WILDCARDS_ANNO
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
fun TypeMappingMode.updateArgumentModeFromAnnotations(
type: KotlinTypeMarker, typeSystem: TypeSystemCommonBackendContext
type: KotlinTypeMarker,
typeSystem: TypeSystemCommonBackendContext,
suppressWildcardsByContainingDeclaration: Boolean? = null,
): TypeMappingMode {
type.suppressWildcardsMode(typeSystem)?.let {
return TypeMappingMode.createWithConstantDeclarationSiteWildcardsMode(
@@ -34,6 +36,20 @@ fun TypeMappingMode.updateArgumentModeFromAnnotations(
)
}
// For example,
// @JvmSuppressWildcards(true)
// fun deepOpen(x: Out<Out<Out<Open>>>) {}
// Instead of the return type, the annotation associated with the declaration indicates that its type signature,
// including return type and parameter types, need to suppress wildcards.
suppressWildcardsByContainingDeclaration?.let {
return TypeMappingMode.createWithConstantDeclarationSiteWildcardsMode(
skipDeclarationSiteWildcards = it,
isForAnnotationParameter = isForAnnotationParameter,
needInlineClassWrapping = needInlineClassWrapping,
mapTypeAliases = mapTypeAliases
)
}
return this
}