Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dev/core/src/com/google/gwt/dev/jjs/impl/MethodInliner.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ public void endVisit(JMethodCall x, Context ctx) {
return;
}

JMethod.Specialization specialization = getCurrentMethod().getSpecialization();
// If we have a specialization, don't inline that away - specializations must be called
// so they aren't pruned or type tightened into uselessness.
if (specialization != null) {
if (specialization.getTargetMethod() == method) {
return;
}
// We might have had a static impl that in turn will have a specialization - ensure we
// also don't inline that specialization away. Note that this check looks for it "backwards"
// by checking if the inlinable method has an instance method, since current method might
// have once had a static method, but it was already removed.
if (specialization.getTargetMethod() == program.instanceMethodForStaticImpl(method)) {
return;
}
}

if (tryInlineMethodCall(x, ctx) == InlineResult.BLACKLIST) {
// Do not try to inline this method again
cannotInline.add(method);
Expand Down
5 changes: 3 additions & 2 deletions user/super/com/google/gwt/emul/java/util/EnumSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static javaemul.internal.InternalPreconditions.checkState;

import javaemul.internal.ArrayHelper;
import javaemul.internal.JsUtils;
import javaemul.internal.annotations.SpecializeMethod;

/**
Expand Down Expand Up @@ -136,7 +137,7 @@ public EnumSet<E> clone() {
@SpecializeMethod(params = Enum.class, target = "containsEnum")
@Override
public boolean contains(Object o) {
return (o instanceof Enum) && containsEnum((Enum) o);
return (o instanceof Enum) && containsEnum(JsUtils.uncheckedCast(o));
}

private boolean containsEnum(Enum e) {
Expand All @@ -151,7 +152,7 @@ public Iterator<E> iterator() {
@SpecializeMethod(params = Enum.class, target = "removeEnum")
@Override
public boolean remove(Object o) {
return (o instanceof Enum) && removeEnum((Enum) o);
return (o instanceof Enum) && removeEnum(JsUtils.uncheckedCast(o));
}

private boolean removeEnum(Enum e) {
Expand Down
6 changes: 3 additions & 3 deletions user/super/com/google/gwt/emul/javaemul/internal/JsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public static native boolean unsafeCastToBoolean(Object bool) /*-{
}-*/;

@UncheckedCast
public static native <T> T uncheckedCast(@DoNotAutobox Object o) /*-{
return o;
}-*/;
public static <T> T uncheckedCast(@DoNotAutobox Object o) {
return (T) o;
}

@UncheckedCast
public static native <T> T getProperty(Object map, String key) /*-{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
* An annotation to mark a given method as being specialized. If the specified
* parameters and return context match of a JMethodCall, then the call
* is retargeted at the specialized version.
* <p/>
* The annotated method must call the target method directly, and the compiler
* must not inline the target method to prevent it from being pruned while it
* still might be used.
*/
@Target(ElementType.METHOD)
@CompilerHint
Expand Down
Loading