Don't generate default method implementation in package facade (just delegation)
This commit is contained in:
@@ -562,14 +562,21 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
||||
if (!isStatic && !isConstructor) {
|
||||
descriptor = descriptor.replace("(", "(" + ownerType.getDescriptor());
|
||||
}
|
||||
|
||||
Method defaultMethod = new Method(isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, descriptor);
|
||||
MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC),
|
||||
isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX,
|
||||
descriptor, null,
|
||||
defaultMethod.getName(),
|
||||
defaultMethod.getDescriptor(), null,
|
||||
getThrownExceptions(functionDescriptor, typeMapper));
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||
generateDefaultImpl(owner, signature, functionDescriptor, isStatic, mv, loadStrategy);
|
||||
|
||||
if (this.owner instanceof PackageFacadeContext) {
|
||||
mv.visitCode();
|
||||
generateStaticDelegateMethodBody(mv, defaultMethod, (PackageFacadeContext) this.owner);
|
||||
endVisit(mv, "default method delegation", callableDescriptorToDeclaration(state.getBindingContext(), functionDescriptor));
|
||||
} else {
|
||||
generateDefaultImpl(owner, signature, functionDescriptor, isStatic, mv, loadStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package foo
|
||||
|
||||
fun simpleFoo(s: Int = 111) {
|
||||
|
||||
}
|
||||
|
||||
// 1 BIPUSH 111
|
||||
// 1 INVOKESTATIC foo/FooPackage-.*\.simpleFoo\$default \(II\)V
|
||||
@@ -72,6 +72,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest("compiler/testData/codegen/bytecodeText/constClosureOptimization.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultDelegation.kt")
|
||||
public void testDefaultDelegation() throws Exception {
|
||||
doTest("compiler/testData/codegen/bytecodeText/defaultDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intConstantNotNull.kt")
|
||||
public void testIntConstantNotNull() throws Exception {
|
||||
doTest("compiler/testData/codegen/bytecodeText/intConstantNotNull.kt");
|
||||
|
||||
Reference in New Issue
Block a user