Devirtualization: bug fix

This commit is contained in:
Igor Chevdar
2018-04-12 19:02:55 +05:00
parent c5c2a080d8
commit be4a811bb7
@@ -355,6 +355,7 @@ internal object Devirtualization {
if (node.receiverType == DataFlowIR.Type.Virtual)
continue@nodeLoop
val receiverType = node.receiverType.resolved()
val vCallReturnType = node.returnType.resolved()
DEBUG_OUTPUT(1) {
println("Adding virtual callsite:")
@@ -368,6 +369,12 @@ internal object Devirtualization {
.forEach { println(" $it") }
}
if (entryPoint == null && vCallReturnType.isFinal) {
// If we are in a library and facing final return type then
// this type can be returned by some user of this library, so propagate it explicitly.
addInstantiatingClass(vCallReturnType)
}
typesVirtualCallSites.getOrPut(receiverType, { mutableListOf() }).add(node)
typeHierarchy.inheritorsOf(receiverType)
.filter { instantiatingClasses.contains(it) }