[FIR] Fix false positive USELESS_CAST on stub types, ^KT-50293 Fixed

This commit is contained in:
Ivan Kochurkin
2022-06-05 21:53:54 +03:00
committed by teamcity
parent 856d14e5f7
commit fd2b4fd497
17 changed files with 34 additions and 24 deletions
@@ -38,7 +38,11 @@ object FirUselessTypeOperationCallChecker : FirTypeOperatorCallChecker() {
when (expression.operation) {
FirOperation.IS -> reporter.reportOn(expression.source, FirErrors.USELESS_IS_CHECK, true, context)
FirOperation.NOT_IS -> reporter.reportOn(expression.source, FirErrors.USELESS_IS_CHECK, false, context)
FirOperation.AS, FirOperation.SAFE_AS -> reporter.reportOn(expression.source, FirErrors.USELESS_CAST, context)
FirOperation.AS, FirOperation.SAFE_AS -> {
if ((arg.typeRef as? FirResolvedTypeRef)?.isFromStubType != true) {
reporter.reportOn(expression.source, FirErrors.USELESS_CAST, context)
}
}
else -> throw AssertionError("Should not be here: ${expression.operation}")
}
}