diff options
Diffstat (limited to 'java/com/google/devtools/build/android/desugar/CoreLibraryInvocationRewriter.java')
-rw-r--r-- | java/com/google/devtools/build/android/desugar/CoreLibraryInvocationRewriter.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/java/com/google/devtools/build/android/desugar/CoreLibraryInvocationRewriter.java b/java/com/google/devtools/build/android/desugar/CoreLibraryInvocationRewriter.java index e83ae41..b4bc98b 100644 --- a/java/com/google/devtools/build/android/desugar/CoreLibraryInvocationRewriter.java +++ b/java/com/google/devtools/build/android/desugar/CoreLibraryInvocationRewriter.java @@ -52,8 +52,18 @@ public class CoreLibraryInvocationRewriter extends ClassVisitor { public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { Class<?> coreInterface = support.getCoreInterfaceRewritingTarget(opcode, owner, name, desc, itf); + String newOwner = support.getMoveTarget(owner, name); - if (coreInterface != null) { + if (newOwner != null) { + checkState(coreInterface == null, + "Can't move and use companion: %s.%s : %s", owner, name, desc); + if (opcode != Opcodes.INVOKESTATIC) { + // assuming a static method + desc = InterfaceDesugaring.companionDefaultMethodDescriptor(owner, desc); + opcode = Opcodes.INVOKESTATIC; + } + itf = false; // assuming a class + } else if (coreInterface != null) { String coreInterfaceName = coreInterface.getName().replace('.', '/'); name = InterfaceDesugaring.normalizeInterfaceMethodName( |