Skip to content

Commit

Permalink
Devirtualization bug fix with main (JetBrains#1945)
Browse files Browse the repository at this point in the history
Added explicit handling of arguments of <main>
  • Loading branch information
homuroll authored and olonho committed Aug 27, 2018
1 parent 32fe05a commit cc28f81
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ internal object Devirtualization {
.filterIsInstance<DataFlowIR.Type.Public>()
.filter { !it.isAbstract }
.forEach { addInstantiatingClass(it) }
} else {
// String is implicitly created as argument of <main>.
addInstantiatingClass(symbolTable.mapType(context.irBuiltIns.stringType))
}
// Traverse call graph from the roots.
rootSet.forEach { dfs(it) }
Expand Down Expand Up @@ -690,6 +693,12 @@ internal object Devirtualization {
private var stack = mutableListOf<DataFlowIR.FunctionSymbol>()

fun build() {
if (entryPoint != null) {
// String arguments are implicitly put into the <args> array parameter of <main>.
concreteClass(symbolTable.mapType(context.irBuiltIns.stringType).resolved()).addEdge(
fieldNode(constraintGraph.arrayItemField)
)
}
rootSet.forEach { createFunctionConstraintGraph(it, true)!! }
while (stack.isNotEmpty()) {
val symbol = stack.pop()
Expand Down

0 comments on commit cc28f81

Please sign in to comment.