From 0eca9d95e156db4d4ab063ba3ec295f870120de4 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 26 Feb 2021 11:52:10 +0300 Subject: [PATCH] Fix missing virtual call detector --- .../classlib/java/util/TSpliterator.java | 36 ++++++++++++++++++- .../model/util/MissingItemsProcessor.java | 6 +--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java b/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java index 311773200..1d1aee282 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java @@ -71,9 +71,16 @@ public interface TSpliterator { } interface OfInt extends OfPrimitive { + @Override + boolean tryAdvance(IntConsumer consumer); + @Override default boolean tryAdvance(Consumer action) { - return tryAdvance((IntConsumer) action::accept); + if (action instanceof IntConsumer) { + return tryAdvance((IntConsumer) action); + } else { + return tryAdvance((IntConsumer) action::accept); + } } @Override @@ -82,9 +89,19 @@ public interface TSpliterator { // continue } } + + @Override + default void forEachRemaining(IntConsumer action) { + while (tryAdvance(action)) { + // continue + } + } } interface OfLong extends OfPrimitive { + @Override + boolean tryAdvance(LongConsumer consumer); + @Override default boolean tryAdvance(Consumer action) { return tryAdvance((LongConsumer) action::accept); @@ -96,9 +113,19 @@ public interface TSpliterator { // continue } } + + @Override + default void forEachRemaining(LongConsumer action) { + while (tryAdvance(action)) { + // continue + } + } } interface OfDouble extends OfPrimitive { + @Override + boolean tryAdvance(DoubleConsumer consumer); + @Override default boolean tryAdvance(Consumer action) { return tryAdvance((DoubleConsumer) action::accept); @@ -110,5 +137,12 @@ public interface TSpliterator { // continue } } + + @Override + default void forEachRemaining(DoubleConsumer action) { + while (tryAdvance(action)) { + // continue + } + } } } diff --git a/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java b/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java index 15d9c741c..5e7822dd4 100644 --- a/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java +++ b/core/src/main/java/org/teavm/model/util/MissingItemsProcessor.java @@ -207,16 +207,12 @@ public class MissingItemsProcessor { if (!checkClass(location, method.getClassName())) { return false; } - if (!reachableMethods.contains(method)) { - return true; - } if (hierarchy.resolve(method) != null) { return true; } - diagnostics.error(new CallLocation(methodRef, location), "Method {{m0}} was not found", - method); + diagnostics.error(new CallLocation(methodRef, location), "Method {{m0}} was not found", method); emitExceptionThrow(location, NoSuchMethodError.class.getName(), "Method not found: " + method); return true; }