New J2K: Do not remove redundant nullability in post precessing for variable if initializer is nullable
This commit is contained in:
committed by
Ilya Kirillov
parent
bbbadb0431
commit
841cd9c749
@@ -406,6 +406,10 @@ object NewJ2KPostProcessingRegistrarImpl : J2KPostProcessingRegistrar {
|
|||||||
if (!element.isLocal) return false
|
if (!element.isLocal) return false
|
||||||
val typeReference = element.typeReference
|
val typeReference = element.typeReference
|
||||||
if (typeReference == null || typeReference.typeElement !is KtNullableType) return false
|
if (typeReference == null || typeReference.typeElement !is KtNullableType) return false
|
||||||
|
val initializerType = element.initializer?.let {
|
||||||
|
it.analyzeInContext(element.getResolutionScope()).getType(it)
|
||||||
|
}
|
||||||
|
if (initializerType?.isNullable() == true) return false
|
||||||
|
|
||||||
return ReferencesSearch.search(element, element.useScope).findAll().mapNotNull { ref ->
|
return ReferencesSearch.search(element, element.useScope).findAll().mapNotNull { ref ->
|
||||||
val parent = (ref.element.parent as? KtExpression)?.asAssignment()
|
val parent = (ref.element.parent as? KtExpression)?.asAssignment()
|
||||||
|
|||||||
Reference in New Issue
Block a user