Misc: Drop utilities for checking nullability/mutability annotations

Types annotated by them are already loaded as inflexible
This commit is contained in:
Alexey Sedunov
2017-11-28 18:26:39 +03:00
parent 84c6f9bf45
commit 6a9317fc57
@@ -56,7 +56,7 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
// Foo<Bar!>! -> Foo<Bar>?
var approximation =
if (isCollection)
(if (isAnnotatedReadOnly()) flexible.upperBound else flexible.lowerBound).makeNullableAsSpecified(!preferNotNull)
flexible.lowerBound.makeNullableAsSpecified(!preferNotNull)
else
if (this is RawType && preferStarForRaw) flexible.upperBound.makeNullableAsSpecified(!preferNotNull)
else
@@ -84,10 +84,6 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
)
}
fun KotlinType.isAnnotatedReadOnly(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_READONLY_ANNOTATION)
fun KotlinType.isAnnotatedNotNull(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NOT_NULL_ANNOTATION)
fun KotlinType.isAnnotatedNullable(): Boolean = hasAnnotationMaybeExternal(JETBRAINS_NULLABLE_ANNOTATION)
private fun KotlinType.hasAnnotationMaybeExternal(fqName: FqName) = with (annotations) {
findAnnotation(fqName) ?: findExternalAnnotation(fqName)
} != null