New J2K: Fix not converted jetbrains nullability annotations for types

it became broken after annotation started to be assigned to type elements
instead of declarations after 4da7d11

#KT-34987 fixed
This commit is contained in:
Ilya Kirillov
2019-11-19 20:06:11 +03:00
parent 3840294f44
commit 92f8432b1e
@@ -21,14 +21,13 @@ class JetbrainsNullableAnnotationsConverter(context: NewJ2kConverterContext) : R
for (annotation in element.annotationList.annotations) {
val nullability = annotation.annotationNullability() ?: continue
when (element) {
is JKVariable -> {
annotationsToRemove += annotation
element.type = JKTypeElement(element.type.type.updateNullability(nullability))
}
is JKMethod -> {
annotationsToRemove += annotation
element.returnType = JKTypeElement(element.returnType.type.updateNullability(nullability))
}
is JKVariable -> element.type
is JKMethod -> element.returnType
is JKTypeElement -> element
else -> null
}?.let { typeElement ->
annotationsToRemove += annotation
typeElement.type = typeElement.type.updateNullability(nullability)
}
}
element.annotationList.annotations -= annotationsToRemove