diff --git a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/components/KtFe10PsiTypeProvider.kt b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/components/KtFe10PsiTypeProvider.kt index 5dd199307bb..13a7d1abcfb 100644 --- a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/components/KtFe10PsiTypeProvider.kt +++ b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/components/KtFe10PsiTypeProvider.kt @@ -73,6 +73,13 @@ internal class KtFe10PsiTypeProvider( typeMapper.typeContext.getOptimalModeForReturnType(type.fe10Type, isAnnotationMethod) KtTypeMappingMode.VALUE_PARAMETER -> typeMapper.typeContext.getOptimalModeForValueParameter(type.fe10Type) + }.let { typeMappingMode -> + // Otherwise, i.e., if we won't skip type with no type arguments, flag overriding might bother a case like: + // @JvmSuppressWildcards(false) Long -> java.lang.Long, not long, even though it should be no-op! + if (type.fe10Type.arguments.isEmpty()) + typeMappingMode + else + typeMappingMode.updateArgumentModeFromAnnotations(type.fe10Type, typeMapper.typeContext) } } diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirPsiTypeProvider.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirPsiTypeProvider.kt index adce38f3bfb..9ed6e5f74d4 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirPsiTypeProvider.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/components/KtFirPsiTypeProvider.kt @@ -59,6 +59,7 @@ import org.jetbrains.kotlin.psi import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.types.model.SimpleTypeMarker +import org.jetbrains.kotlin.types.updateArgumentModeFromAnnotations import java.text.StringCharacterIterator internal class KtFirPsiTypeProvider( @@ -89,6 +90,7 @@ internal class KtFirPsiTypeProvider( private fun KtTypeMappingMode.toTypeMappingMode(type: KtType, isAnnotationMethod: Boolean): TypeMappingMode { require(type is KtFirType) + val expandedType = type.coneType.fullyExpandedType(rootModuleSession) return when (this) { KtTypeMappingMode.DEFAULT -> TypeMappingMode.DEFAULT KtTypeMappingMode.DEFAULT_UAST -> TypeMappingMode.DEFAULT_UAST @@ -97,13 +99,18 @@ internal class KtFirPsiTypeProvider( KtTypeMappingMode.SUPER_TYPE_KOTLIN_COLLECTIONS_AS_IS -> TypeMappingMode.SUPER_TYPE_KOTLIN_COLLECTIONS_AS_IS KtTypeMappingMode.RETURN_TYPE_BOXED -> TypeMappingMode.RETURN_TYPE_BOXED KtTypeMappingMode.RETURN_TYPE -> { - val expandedType = type.coneType.fullyExpandedType(rootModuleSession) rootModuleSession.jvmTypeMapper.typeContext.getOptimalModeForReturnType(expandedType, isAnnotationMethod) } KtTypeMappingMode.VALUE_PARAMETER -> { - val expandedType = type.coneType.fullyExpandedType(rootModuleSession) rootModuleSession.jvmTypeMapper.typeContext.getOptimalModeForValueParameter(expandedType) } + }.let { typeMappingMode -> + // Otherwise, i.e., if we won't skip type with no type arguments, flag overriding might bother a case like: + // @JvmSuppressWildcards(false) Long -> java.lang.Long, not long, even though it should be no-op! + if (expandedType.typeArguments.isEmpty()) + typeMappingMode + else + typeMappingMode.updateArgumentModeFromAnnotations(expandedType, rootModuleSession.jvmTypeMapper.typeContext) } } diff --git a/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/wildcardSuppression_true.txt b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/wildcardSuppression_true.txt index c0bbe103336..5cceaeb84e1 100644 --- a/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/wildcardSuppression_true.txt +++ b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/wildcardSuppression_true.txt @@ -1,2 +1,2 @@ KtType: @kotlin.jvm.JvmSuppressWildcards(suppress = true) (AnimatedContentTransitionScope.() -> EnterTransition?)? -PsiType: PsiType:Function1, ? extends EnterTransition> +PsiType: PsiType:Function1, EnterTransition>