diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java index 5302b9007..699350acb 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyGraphBuilder.java @@ -338,9 +338,20 @@ class DependencyGraphBuilder { StringBuilder sb = new StringBuilder(); for (int i = 0; i < dimensions.size(); ++i) { sb.append('['); + itemType = ((ValueType.Array)itemType).getItemType(); + } + String itemTypeStr; + if (itemType instanceof ValueType.Object) { + itemTypeStr = ((ValueType.Object)itemType).getClassName(); + } else { + itemTypeStr = itemType.toString(); + } + sb.append(itemTypeStr); + DependencyNode node = nodes[receiver.getIndex()]; + for (int i = 0; i < dimensions.size(); ++i) { + node.propagate(dependencyChecker.getType(sb.substring(i, sb.length()))); + node = node.getArrayItem(); } - sb.append(itemType); - nodes[receiver.getIndex()].propagate(dependencyChecker.getType(sb.toString())); String className = extractClassName(itemType); if (className != null) { dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation)); diff --git a/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java b/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java index 9c77fe005..12686b2d4 100644 --- a/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java +++ b/teavm-core/src/main/java/org/teavm/dependency/DependencyNode.java @@ -120,6 +120,11 @@ public class DependencyNode implements ValueDependencyInfo { if (DependencyChecker.shouldLog) { arrayItemNode.tag = tag + "["; } + arrayItemNode.addConsumer(new DependencyConsumer() { + @Override public void consume(DependencyAgentType type) { + DependencyNode.this.propagate(type); + } + }); } return arrayItemNode; }