diff --git a/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt b/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt index 524952603..b75765fb9 100644 --- a/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt +++ b/jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/RawInstListBuilder.kt @@ -217,27 +217,33 @@ private fun typeLub(first: TypeName, second: TypeName): TypeName { if (first == TOP || second == TOP) return TOP - if (first == NULL) { - return if (second.isPrimitive) TOP else second + if (first.isPrimitive) { + return primitiveTypeLub(first, second) } - if (second == NULL) { - return if (first.isPrimitive) TOP else first + if (second.isPrimitive) { + return primitiveTypeLub(second, first) } - if (first.isPrimitive || second.isPrimitive) { - if (first.typeName == PredefinedPrimitives.Int) { - return second - } + return OBJECT_TYPE_NAME +} - if (second.typeName == PredefinedPrimitives.Int) { - return first - } +private fun primitiveTypeLub(primitiveType: TypeName, other: TypeName): TypeName { + if (primitiveType == NULL) { + return if (other.isPrimitive) TOP else other + } - return TOP + if (!other.isPrimitive) return TOP + + if (primitiveType.typeName == PredefinedPrimitives.Int) { + return other } - return OBJECT_TYPE_NAME + if (other.typeName == PredefinedPrimitives.Int) { + return primitiveType + } + + return TOP } private fun List<*>?.parseLocals(): Array { @@ -1536,12 +1542,11 @@ class RawInstListBuilder( @Suppress("UNCHECKED_CAST") return mergeWithPresentFrames(frames as Map, curInsn, localTypes, stackTypes) } else { - return mergeWithMissedFrames(frames, curInsn, localTypes, stackTypes) + return mergeWithMissedFrames(curInsn, localTypes, stackTypes) } } private fun mergeWithMissedFrames( - frames: Map, curNode: LabelNode, localTypes: Array, stackTypes: List, @@ -1639,6 +1644,8 @@ class RawInstListBuilder( type = typeLub(type, frameType) } + if (type == TOP) return TOP + // If we have several variables types for one register we have to search right type in debug info otherwise we cannot guarantee anything val debugType = findLocalVariableWithInstruction(variable, curLabel) ?.let { Type.getType(it.desc) }