Removed old default generation

This commit is contained in:
Michael Bogdanov
2016-02-01 15:04:34 +03:00
parent a90f8122bd
commit 328b9bfeda
5 changed files with 4 additions and 45 deletions
@@ -676,15 +676,6 @@ public class FunctionCodegen {
generateDefaultImplBody(owner, functionDescriptor, mv, loadStrategy, function, memberCodegen, defaultMethod);
endVisit(mv, "default method", getSourceFromDescriptor(functionDescriptor));
}
generateOldDefaultForFun(defaultMethod,
JvmDeclarationOriginKt.Synthetic(function, functionDescriptor),
flags,
getThrownExceptions(functionDescriptor, typeMapper),
(owner.getContextKind() == OwnerKind.DEFAULT_IMPLS ?
typeMapper.mapDefaultImpls((ClassDescriptor) functionDescriptor.getContainingDeclaration()) :
typeMapper.mapImplementationOwner(functionDescriptor)).getInternalName()
);
}
}
@@ -767,38 +758,6 @@ public class FunctionCodegen {
iv.visitLabel(end);
}
private void generateOldDefaultForFun(
Method newDefaultMethod,
JvmDeclarationOrigin origin,
int flags,
String[] exceptions,
String owner
) {
if ("<init>".equals(newDefaultMethod.getName())) {
return;
}
String oldSignature = newDefaultMethod.getDescriptor().replaceFirst("Ljava/lang/Object;\\)", ")");
MethodVisitor mv = v.newMethod(
origin,
flags,
newDefaultMethod.getName(),
oldSignature,
null,
exceptions
);
mv.visitCode();
int index = 0;
InstructionAdapter iv = new InstructionAdapter(mv);
for (Type type: Type.getArgumentTypes(oldSignature)) {
iv.load(index, type);
index += type.getSize();
}
iv.aconst(null);
iv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, newDefaultMethod.getName(), newDefaultMethod.getDescriptor(), false);
iv.areturn(newDefaultMethod.getReturnType());
mv.visitEnd();
}
@NotNull
private static FrameMap createFrameMap(
@NotNull GenerationState state,
@@ -9,5 +9,5 @@ class A {
}
}
// Test argument reordering when call site argument order differs from declaration one: 18 + 1 for super call check
// 19 LOAD
// 13 LOAD
// 5 STORE
@@ -8,5 +8,5 @@ class A {
}
}
// Test there is no argument reordering when call site argument order same as declaration one: 15 + 1 for super call check
// 16 LOAD
// 10 LOAD
// 2 STORE
@@ -14,4 +14,4 @@ interface A {
// 1 foo\(
// 1 getProp
// 3 defaultFun\$
// 1 defaultFun\$
@@ -1,4 +1,4 @@
fun foo(a: Int = 1) {}
// 0 _DefaultPackage.foo
// 2 INVOKESTATIC TopLevelFunWithDefaultArgsKt\.foo
// 1 INVOKESTATIC TopLevelFunWithDefaultArgsKt\.foo