[FIR] Don't create smartcasts to error types
This commit is contained in:
@@ -161,6 +161,7 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun addTypeStatement(flow: PersistentFlow, statement: TypeStatement) {
|
override fun addTypeStatement(flow: PersistentFlow, statement: TypeStatement) {
|
||||||
|
if (statement.isEmpty) return
|
||||||
with(flow) {
|
with(flow) {
|
||||||
approvedTypeStatements = approvedTypeStatements.addTypeStatement(statement)
|
approvedTypeStatements = approvedTypeStatements.addTypeStatement(statement)
|
||||||
if (previousFlow != null) {
|
if (previousFlow != null) {
|
||||||
@@ -173,6 +174,7 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun addImplication(flow: PersistentFlow, implication: Implication) {
|
override fun addImplication(flow: PersistentFlow, implication: Implication) {
|
||||||
|
if ((implication.effect as? TypeStatement)?.isEmpty == true) return
|
||||||
if (implication.condition == implication.effect) return
|
if (implication.condition == implication.effect) return
|
||||||
with(flow) {
|
with(flow) {
|
||||||
val variable = implication.condition.variable
|
val variable = implication.condition.variable
|
||||||
|
|||||||
@@ -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.AbstractFirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
|
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
|
|
||||||
// --------------------------------------- Variables ---------------------------------------
|
// --------------------------------------- Variables ---------------------------------------
|
||||||
@@ -207,8 +208,16 @@ infix fun OperationStatement.implies(effect: Statement<*>): Implication = Implic
|
|||||||
|
|
||||||
infix fun RealVariable.typeEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, types, HashSet())
|
infix fun RealVariable.typeEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, types, HashSet())
|
||||||
infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement =
|
infix fun RealVariable.typeEq(type: ConeKotlinType): TypeStatement =
|
||||||
MutableTypeStatement(this, HashSet<ConeKotlinType>().apply { this += type }, HashSet())
|
if (type !is ConeClassErrorType) {
|
||||||
|
MutableTypeStatement(this, HashSet<ConeKotlinType>().apply { this += type }, HashSet())
|
||||||
|
} else {
|
||||||
|
MutableTypeStatement(this)
|
||||||
|
}
|
||||||
|
|
||||||
infix fun RealVariable.typeNotEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, HashSet(), types)
|
infix fun RealVariable.typeNotEq(types: MutableSet<ConeKotlinType>): TypeStatement = MutableTypeStatement(this, HashSet(), types)
|
||||||
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
infix fun RealVariable.typeNotEq(type: ConeKotlinType): TypeStatement =
|
||||||
MutableTypeStatement(this, HashSet(), HashSet<ConeKotlinType>().apply { this += type })
|
if (type !is ConeClassErrorType) {
|
||||||
|
MutableTypeStatement(this, HashSet(), HashSet<ConeKotlinType>().apply { this += type })
|
||||||
|
} else {
|
||||||
|
MutableTypeStatement(this)
|
||||||
|
}
|
||||||
+3
-3
@@ -38,7 +38,7 @@ fun test() {
|
|||||||
1 + platformJ
|
1 + platformJ
|
||||||
|
|
||||||
platformNN + 1
|
platformNN + 1
|
||||||
platformN + 1
|
platformN <!INAPPLICABLE_CANDIDATE!>+<!> 1
|
||||||
platformJ + 1
|
platformJ + 1
|
||||||
|
|
||||||
1 plus platformNN
|
1 plus platformNN
|
||||||
@@ -46,10 +46,10 @@ fun test() {
|
|||||||
1 plus platformJ
|
1 plus platformJ
|
||||||
|
|
||||||
platformNN plus 1
|
platformNN plus 1
|
||||||
platformN plus 1
|
platformN <!INAPPLICABLE_CANDIDATE!>plus<!> 1
|
||||||
platformJ plus 1
|
platformJ plus 1
|
||||||
|
|
||||||
platformNN += 1
|
platformNN += 1
|
||||||
platformN += 1
|
<!UNRESOLVED_REFERENCE!>platformN += 1<!>
|
||||||
platformJ += 1
|
platformJ += 1
|
||||||
}
|
}
|
||||||
+1
-1
@@ -12,7 +12,7 @@ operator fun Long?.inc() = this?.let { it + 1 }
|
|||||||
fun bar(arg: Long?): Long {
|
fun bar(arg: Long?): Long {
|
||||||
var i = arg
|
var i = arg
|
||||||
if (i++ == 5L) {
|
if (i++ == 5L) {
|
||||||
return i<!INAPPLICABLE_CANDIDATE!>--<!> + i
|
return i<!INAPPLICABLE_CANDIDATE!>--<!> <!INAPPLICABLE_CANDIDATE!>+<!> i
|
||||||
}
|
}
|
||||||
if (i++ == 7L) {
|
if (i++ == 7L) {
|
||||||
return i++ <!INAPPLICABLE_CANDIDATE!>+<!> i
|
return i++ <!INAPPLICABLE_CANDIDATE!>+<!> i
|
||||||
|
|||||||
Reference in New Issue
Block a user