diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt index cec3738407f..dca078597ed 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt @@ -161,6 +161,7 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste } override fun addTypeStatement(flow: PersistentFlow, statement: TypeStatement) { + if (statement.isEmpty) return with(flow) { approvedTypeStatements = approvedTypeStatements.addTypeStatement(statement) if (previousFlow != null) { @@ -173,6 +174,7 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste } override fun addImplication(flow: PersistentFlow, implication: Implication) { + if ((implication.effect as? TypeStatement)?.isEmpty == true) return if (implication.condition == implication.effect) return with(flow) { val variable = implication.condition.variable diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/model.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/model.kt index 9f16780771d..ad3b4c4d918 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/model.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/model.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.dfa.Operation import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.types.ConeClassErrorType import org.jetbrains.kotlin.fir.types.ConeKotlinType // --------------------------------------- Variables --------------------------------------- @@ -207,8 +208,16 @@ infix fun OperationStatement.implies(effect: Statement<*>): Implication = Implic infix fun RealVariable.typeEq(types: MutableSet): TypeStatement = MutableTypeStatement(this, types, HashSet()) infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement = - MutableTypeStatement(this, HashSet().apply { this += type }, HashSet()) + if (type !is ConeClassErrorType) { + MutableTypeStatement(this, HashSet().apply { this += type }, HashSet()) + } else { + MutableTypeStatement(this) + } infix fun RealVariable.typeNotEq(types: MutableSet): TypeStatement = MutableTypeStatement(this, HashSet(), types) infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement = - MutableTypeStatement(this, HashSet(), HashSet().apply { this += type }) \ No newline at end of file + if (type !is ConeClassErrorType) { + MutableTypeStatement(this, HashSet(), HashSet().apply { this += type }) + } else { + MutableTypeStatement(this) + } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.fir.kt index c70fa9c521c..2207ca812c9 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.fir.kt @@ -38,7 +38,7 @@ fun test() { 1 + platformJ platformNN + 1 - platformN + 1 + platformN + 1 platformJ + 1 1 plus platformNN @@ -46,10 +46,10 @@ fun test() { 1 plus platformJ platformNN plus 1 - platformN plus 1 + platformN plus 1 platformJ plus 1 platformNN += 1 - platformN += 1 + platformN += 1 platformJ += 1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/plusplusMinusminus.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/plusplusMinusminus.fir.kt index dc2a9386d1f..3715e9d1bfd 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/plusplusMinusminus.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/plusplusMinusminus.fir.kt @@ -12,7 +12,7 @@ operator fun Long?.inc() = this?.let { it + 1 } fun bar(arg: Long?): Long { var i = arg if (i++ == 5L) { - return i-- + i + return i-- + i } if (i++ == 7L) { return i++ + i