FE: slowly refactor extractQualifiersFromAnnotations 1
That code is convoluted, better take it slow to avoid accidentally breaking (or fixing) anything.
This commit is contained in:
+21
-17
@@ -273,6 +273,20 @@ private class SignatureParts(
|
|||||||
composeAnnotations(typeContainer.annotations, typeOrBound.annotations)
|
composeAnnotations(typeContainer.annotations, typeOrBound.annotations)
|
||||||
} else typeOrBound.annotations
|
} else typeOrBound.annotations
|
||||||
|
|
||||||
|
val annotationsMutability = annotationTypeQualifierResolver.extractMutability(composedAnnotation)
|
||||||
|
val annotationsNullability = annotationTypeQualifierResolver.extractNullability(composedAnnotation) {
|
||||||
|
(this is LazyJavaAnnotationDescriptor && (isFreshlySupportedTypeUseAnnotation || typeParameterBounds) && !areImprovementsInStrictMode) ||
|
||||||
|
(this is PossiblyExternalAnnotationDescriptor && isIdeExternalAnnotation)
|
||||||
|
}.takeUnless { type == null }
|
||||||
|
|
||||||
|
if (annotationsNullability != null) {
|
||||||
|
return JavaTypeQualifiers(
|
||||||
|
annotationsNullability.qualifier, annotationsMutability,
|
||||||
|
annotationsNullability.qualifier == NullabilityQualifier.NOT_NULL && typeOrBound.isTypeParameter(),
|
||||||
|
annotationsNullability.isForWarningOnly
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val defaultTypeQualifier = (
|
val defaultTypeQualifier = (
|
||||||
if (isHeadTypeConstructor)
|
if (isHeadTypeConstructor)
|
||||||
containerContext.defaultTypeQualifiers?.get(containerApplicabilityType)
|
containerContext.defaultTypeQualifiers?.get(containerApplicabilityType)
|
||||||
@@ -287,27 +301,17 @@ private class SignatureParts(
|
|||||||
|
|
||||||
val (nullabilityFromBoundsForTypeBasedOnTypeParameter, isTypeParameterWithNotNullableBounds) =
|
val (nullabilityFromBoundsForTypeBasedOnTypeParameter, isTypeParameterWithNotNullableBounds) =
|
||||||
typeOrBound.nullabilityInfoBoundsForTypeParameterUsage()
|
typeOrBound.nullabilityInfoBoundsForTypeParameterUsage()
|
||||||
|
val nullabilityInfo = computeNullabilityInfoInTheAbsenceOfExplicitAnnotation(
|
||||||
val annotationsNullability = annotationTypeQualifierResolver.extractNullability(composedAnnotation) {
|
nullabilityFromBoundsForTypeBasedOnTypeParameter,
|
||||||
(this is LazyJavaAnnotationDescriptor && (isFreshlySupportedTypeUseAnnotation || typeParameterBounds) && !areImprovementsInStrictMode) ||
|
defaultTypeQualifier,
|
||||||
(this is PossiblyExternalAnnotationDescriptor && isIdeExternalAnnotation)
|
typeParameterForArgument
|
||||||
}.takeUnless { type == null }
|
)
|
||||||
val nullabilityInfo =
|
|
||||||
annotationsNullability
|
|
||||||
?: computeNullabilityInfoInTheAbsenceOfExplicitAnnotation(
|
|
||||||
nullabilityFromBoundsForTypeBasedOnTypeParameter,
|
|
||||||
defaultTypeQualifier,
|
|
||||||
typeParameterForArgument
|
|
||||||
)
|
|
||||||
|
|
||||||
val isNotNullTypeParameter =
|
val isNotNullTypeParameter =
|
||||||
if (annotationsNullability != null)
|
isTypeParameterWithNotNullableBounds || defaultTypeQualifier?.makesTypeParameterNotNull == true
|
||||||
annotationsNullability.qualifier == NullabilityQualifier.NOT_NULL
|
|
||||||
else
|
|
||||||
isTypeParameterWithNotNullableBounds || defaultTypeQualifier?.makesTypeParameterNotNull == true
|
|
||||||
|
|
||||||
return JavaTypeQualifiers(
|
return JavaTypeQualifiers(
|
||||||
nullabilityInfo?.qualifier, annotationTypeQualifierResolver.extractMutability(composedAnnotation),
|
nullabilityInfo?.qualifier, annotationsMutability,
|
||||||
isNotNullTypeParameter = isNotNullTypeParameter && typeOrBound.isTypeParameter(),
|
isNotNullTypeParameter = isNotNullTypeParameter && typeOrBound.isTypeParameter(),
|
||||||
isNullabilityQualifierForWarning = nullabilityInfo?.isForWarningOnly == true
|
isNullabilityQualifierForWarning = nullabilityInfo?.isForWarningOnly == true
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user