Refine redundant null checks interpreter
The main change here is addition of a check that NotNullBasicValue instances
are not being created for non-reference types
Exactly this change should be used instead of f25f0db10e
The latter commit lead to problem described in the KT-14242 issue:
v.getType().getSort() == w.getType().getSort() && (v.getType().getSort() != Type.OBJECT || v.equals(w))
Problem is that the condition above returns true without calling `v.equals(w)`,
because the sort of type is ARRAY, not OBJECT, so testArray was being treated
as NotNullable erroneously
So the second part of this change is effectively revering mentioned commit
#KT-14242 Fixed
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// See KT-14242
|
||||
var x = 1
|
||||
fun box(): String {
|
||||
val testArray: Array<String?>? = when (1) {
|
||||
x -> null
|
||||
else -> arrayOfNulls<String>(0)
|
||||
}
|
||||
|
||||
// Must not be NPE here
|
||||
val size = testArray?.size
|
||||
|
||||
return size?.toString() ?: "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user