mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[kotlin-dfa] Fix anchor for array store (KTIJ-24314)
GitOrigin-RevId: 795f7978bd12cc4cf02abff89c913b9cc5583b14
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc26ba2b00
commit
d288fc7bb1
@@ -41,4 +41,9 @@ public class FoldArrayInstruction extends EvalInstruction {
|
||||
DfType type = SpecialField.ARRAY_LENGTH.asDfType(myTargetType.meet(DfTypes.NOT_NULL_OBJECT), DfTypes.intValue(arguments.length));
|
||||
return factory.fromDfType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FOLD_ARRAY " + myTargetType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +348,13 @@ class KtControlFlowBuilder(val factory: DfaValueFactory, val context: KtExpressi
|
||||
for (idx in indexes) {
|
||||
processExpression(idx)
|
||||
val lastIndex = idx == indexes.last()
|
||||
val anchor = if (lastIndex) KotlinExpressionAnchor(expr) else null
|
||||
val anchor = if (lastIndex) {
|
||||
if (storedValue != null)
|
||||
KotlinExpressionAnchor(PsiTreeUtil.findCommonParent(expr, storedValue) as? KtExpression ?: expr)
|
||||
else
|
||||
KotlinExpressionAnchor(expr)
|
||||
}
|
||||
else null
|
||||
val expectedType = if (lastIndex) expr.getKotlinType()?.toDfType() ?: DfType.TOP else DfType.TOP
|
||||
var indexType = idx.getKotlinType()
|
||||
val constructor = indexType?.constructor as? IntegerLiteralTypeConstructor
|
||||
|
||||
@@ -56,4 +56,10 @@ fun nullableArraySize(x : Array<Int>?) {
|
||||
|
||||
}
|
||||
}
|
||||
data class X(val x: Int)
|
||||
data class X(val x: Int)
|
||||
fun storeNull() {
|
||||
// KTIJ-24314
|
||||
val array: Array<Int?> = arrayOf(0)
|
||||
array[0] = 1
|
||||
array[0] = null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user