FE: remove ? enhancement code that is never used

Using `starProjectionType` to enhance `?` is pointless because
 1. we explicitly ignore nullability annotations for `?` below;
 2. mutability is irrelevant;
 3. `starProjectionType` never returns references to other type
    parameters due to how the type substitutor works.
This commit is contained in:
pyos
2021-08-16 14:32:44 +02:00
committed by teamcityserver
parent a8b09a2016
commit c85329905c
2 changed files with 6 additions and 12 deletions
@@ -34,7 +34,6 @@ abstract class AbstractSignatureParts<Annotation : Any> {
abstract val KotlinTypeMarker.fqNameUnsafe: FqNameUnsafe? abstract val KotlinTypeMarker.fqNameUnsafe: FqNameUnsafe?
abstract fun KotlinTypeMarker.isEqual(other: KotlinTypeMarker): Boolean abstract fun KotlinTypeMarker.isEqual(other: KotlinTypeMarker): Boolean
abstract val TypeParameterMarker.starProjectedType: KotlinTypeMarker?
abstract val TypeParameterMarker.isFromJava: Boolean abstract val TypeParameterMarker.isFromJava: Boolean
open val KotlinTypeMarker.isNotNullTypeParameterCompat: Boolean open val KotlinTypeMarker.isNotNullTypeParameterCompat: Boolean
@@ -71,11 +70,11 @@ abstract class AbstractSignatureParts<Annotation : Any> {
} }
val isHeadTypeConstructor = typeParameterForArgument == null val isHeadTypeConstructor = typeParameterForArgument == null
val typeOrBound = type ?: typeParameterForArgument?.starProjectedType ?: return JavaTypeQualifiers.NONE val typeAnnotations = type?.annotations ?: emptyList()
val typeParameterUse = with(typeSystem) { typeOrBound.typeConstructor().getTypeParameterClassifier() } val typeParameterUse = with(typeSystem) { type?.typeConstructor()?.getTypeParameterClassifier() }
val typeParameterBounds = containerApplicabilityType == AnnotationQualifierApplicabilityType.TYPE_PARAMETER_BOUNDS val typeParameterBounds = containerApplicabilityType == AnnotationQualifierApplicabilityType.TYPE_PARAMETER_BOUNDS
val composedAnnotation = when { val composedAnnotation = when {
!isHeadTypeConstructor -> typeOrBound.annotations !isHeadTypeConstructor -> typeAnnotations
!typeParameterBounds && enableImprovementsInStrictMode -> !typeParameterBounds && enableImprovementsInStrictMode ->
// We don't apply container type use annotations to avoid double applying them like with arrays: // We don't apply container type use annotations to avoid double applying them like with arrays:
// @NotNull Integer [] f15(); // @NotNull Integer [] f15();
@@ -83,14 +82,13 @@ abstract class AbstractSignatureParts<Annotation : Any> {
// and to entire array (as METHOD annotation). // and to entire array (as METHOD annotation).
// In other words, we prefer TYPE_USE target of an annotation, and apply the annotation only according to it, if it's present. // In other words, we prefer TYPE_USE target of an annotation, and apply the annotation only according to it, if it's present.
// See KT-24392 for more details. // See KT-24392 for more details.
containerAnnotations.filter { !annotationTypeQualifierResolver.isTypeUseAnnotation(it) } + typeOrBound.annotations containerAnnotations.filter { !annotationTypeQualifierResolver.isTypeUseAnnotation(it) } + typeAnnotations
else -> containerAnnotations + typeOrBound.annotations else -> containerAnnotations + typeAnnotations
} }
val annotationsMutability = annotationTypeQualifierResolver.extractMutability(composedAnnotation) val annotationsMutability = annotationTypeQualifierResolver.extractMutability(composedAnnotation)
val annotationsNullability = annotationTypeQualifierResolver.extractNullability(composedAnnotation) { forceWarning } val annotationsNullability = annotationTypeQualifierResolver.extractNullability(composedAnnotation) { forceWarning }
if (annotationsNullability != null) {
if (type != null && annotationsNullability != null) {
return JavaTypeQualifiers( return JavaTypeQualifiers(
annotationsNullability.qualifier, annotationsMutability, annotationsNullability.qualifier, annotationsMutability,
annotationsNullability.qualifier == NullabilityQualifier.NOT_NULL && typeParameterUse != null, annotationsNullability.qualifier == NullabilityQualifier.NOT_NULL && typeParameterUse != null,
@@ -98,7 +96,6 @@ abstract class AbstractSignatureParts<Annotation : Any> {
) )
} }
// TODO: check whether the code below works properly for star projections (when typeOrBound != type)
val applicabilityType = when { val applicabilityType = when {
isHeadTypeConstructor || typeParameterBounds -> containerApplicabilityType isHeadTypeConstructor || typeParameterBounds -> containerApplicabilityType
else -> AnnotationQualifierApplicabilityType.TYPE_USE else -> AnnotationQualifierApplicabilityType.TYPE_USE
@@ -251,9 +251,6 @@ private class SignatureParts(
override fun KotlinTypeMarker.isEqual(other: KotlinTypeMarker): Boolean = override fun KotlinTypeMarker.isEqual(other: KotlinTypeMarker): Boolean =
containerContext.components.kotlinTypeChecker.equalTypes(this as KotlinType, other as KotlinType) containerContext.components.kotlinTypeChecker.equalTypes(this as KotlinType, other as KotlinType)
override val TypeParameterMarker.starProjectedType: KotlinType
get() = (this as TypeParameterDescriptor).starProjectionType()
override val TypeParameterMarker.isFromJava: Boolean override val TypeParameterMarker.isFromJava: Boolean
get() = this is LazyJavaTypeParameterDescriptor get() = this is LazyJavaTypeParameterDescriptor
} }