AA: honor wildcard suppression on type during type conversion
^KT-61734
This commit is contained in:
+7
@@ -73,6 +73,13 @@ internal class KtFe10PsiTypeProvider(
|
|||||||
typeMapper.typeContext.getOptimalModeForReturnType(type.fe10Type, isAnnotationMethod)
|
typeMapper.typeContext.getOptimalModeForReturnType(type.fe10Type, isAnnotationMethod)
|
||||||
KtTypeMappingMode.VALUE_PARAMETER ->
|
KtTypeMappingMode.VALUE_PARAMETER ->
|
||||||
typeMapper.typeContext.getOptimalModeForValueParameter(type.fe10Type)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -59,6 +59,7 @@ import org.jetbrains.kotlin.psi
|
|||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||||
|
import org.jetbrains.kotlin.types.updateArgumentModeFromAnnotations
|
||||||
import java.text.StringCharacterIterator
|
import java.text.StringCharacterIterator
|
||||||
|
|
||||||
internal class KtFirPsiTypeProvider(
|
internal class KtFirPsiTypeProvider(
|
||||||
@@ -89,6 +90,7 @@ internal class KtFirPsiTypeProvider(
|
|||||||
|
|
||||||
private fun KtTypeMappingMode.toTypeMappingMode(type: KtType, isAnnotationMethod: Boolean): TypeMappingMode {
|
private fun KtTypeMappingMode.toTypeMappingMode(type: KtType, isAnnotationMethod: Boolean): TypeMappingMode {
|
||||||
require(type is KtFirType)
|
require(type is KtFirType)
|
||||||
|
val expandedType = type.coneType.fullyExpandedType(rootModuleSession)
|
||||||
return when (this) {
|
return when (this) {
|
||||||
KtTypeMappingMode.DEFAULT -> TypeMappingMode.DEFAULT
|
KtTypeMappingMode.DEFAULT -> TypeMappingMode.DEFAULT
|
||||||
KtTypeMappingMode.DEFAULT_UAST -> TypeMappingMode.DEFAULT_UAST
|
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.SUPER_TYPE_KOTLIN_COLLECTIONS_AS_IS -> TypeMappingMode.SUPER_TYPE_KOTLIN_COLLECTIONS_AS_IS
|
||||||
KtTypeMappingMode.RETURN_TYPE_BOXED -> TypeMappingMode.RETURN_TYPE_BOXED
|
KtTypeMappingMode.RETURN_TYPE_BOXED -> TypeMappingMode.RETURN_TYPE_BOXED
|
||||||
KtTypeMappingMode.RETURN_TYPE -> {
|
KtTypeMappingMode.RETURN_TYPE -> {
|
||||||
val expandedType = type.coneType.fullyExpandedType(rootModuleSession)
|
|
||||||
rootModuleSession.jvmTypeMapper.typeContext.getOptimalModeForReturnType(expandedType, isAnnotationMethod)
|
rootModuleSession.jvmTypeMapper.typeContext.getOptimalModeForReturnType(expandedType, isAnnotationMethod)
|
||||||
}
|
}
|
||||||
KtTypeMappingMode.VALUE_PARAMETER -> {
|
KtTypeMappingMode.VALUE_PARAMETER -> {
|
||||||
val expandedType = type.coneType.fullyExpandedType(rootModuleSession)
|
|
||||||
rootModuleSession.jvmTypeMapper.typeContext.getOptimalModeForValueParameter(expandedType)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
KtType: @kotlin.jvm.JvmSuppressWildcards(suppress = true) (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?
|
KtType: @kotlin.jvm.JvmSuppressWildcards(suppress = true) (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?
|
||||||
PsiType: PsiType:Function1<? super AnimatedContentTransitionScope<NavBackStackEntry>, ? extends EnterTransition>
|
PsiType: PsiType:Function1<AnimatedContentTransitionScope<NavBackStackEntry>, EnterTransition>
|
||||||
|
|||||||
Reference in New Issue
Block a user