Redundant object type check: fix problem highlighting #KT-22484 Fixed

This commit is contained in:
Mikhail Glukhikh
2018-02-08 11:46:46 +03:00
parent 901ae087bc
commit d554a4234d
@@ -38,17 +38,14 @@ class RedundantObjectTypeCheckInspection : AbstractKotlinInspection() {
super.visitIsExpression(expression) super.visitIsExpression(expression)
val typeReference = expression.typeReference ?: return val typeReference = expression.typeReference ?: return
if (!typeReference.isObject()) return if (!typeReference.isObject()) return
registerProblem(expression.operationReference, ReplaceWithEqualityFix(expression.isNegated))
}
private fun registerProblem(element: KtElement, quickFix: LocalQuickFix) {
holder.registerProblem( holder.registerProblem(
element, expression.operationReference,
TextRange(0, 2), TextRange(0, if (expression.isNegated) 3 else 2),
"Redundant type checks for object", "Redundant type checks for object",
quickFix ReplaceWithEqualityFix(expression.isNegated)
) )
} }
} }
} }
} }