Generate bridges for delegates

This commit is contained in:
Alexander Udalov
2012-10-29 22:50:26 +04:00
parent dc5174670d
commit 3ca976ee77
6 changed files with 69 additions and 9 deletions
@@ -818,6 +818,8 @@ public class FunctionCodegen extends GenerationStateAware {
iv.areturn(delegateMethod.getReturnType());
endVisit(mv, "delegate method", descriptorToDeclaration(bindingContext, functionDescriptor));
generateBridgeIfNeeded(owner, state, v, jvmDelegateMethodSignature.getAsmMethod(), functionDescriptor);
}
}
}
@@ -316,17 +316,17 @@ public class PropertyCodegen extends GenerationStateAware {
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
}
public void genDelegate(PropertyDescriptor declaration, PropertyDescriptor overriddenDescriptor, StackValue field) {
ClassDescriptor toClass = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
public void genDelegate(PropertyDescriptor delegate, PropertyDescriptor overridden, StackValue field) {
ClassDescriptor toClass = (ClassDescriptor) overridden.getContainingDeclaration();
JvmMethodSignature getterSignature =
typeMapper.mapGetterSignature(declaration.getOriginal(), OwnerKind.IMPLEMENTATION).getJvmMethodSignature();
functionCodegen.genDelegate(declaration.getGetter(), toClass, field, getterSignature, getterSignature);
functionCodegen.genDelegate(delegate.getGetter(), toClass, field,
typeMapper.mapGetterSignature(delegate, OwnerKind.IMPLEMENTATION).getJvmMethodSignature(),
typeMapper.mapGetterSignature(overridden.getOriginal(), OwnerKind.IMPLEMENTATION).getJvmMethodSignature());
if (declaration.isVar()) {
JvmMethodSignature setterSignature =
typeMapper.mapSetterSignature(declaration.getOriginal(), OwnerKind.IMPLEMENTATION).getJvmMethodSignature();
functionCodegen.genDelegate(declaration.getSetter(), toClass, field, setterSignature, setterSignature);
if (delegate.isVar()) {
functionCodegen.genDelegate(delegate.getSetter(), toClass, field,
typeMapper.mapSetterSignature(delegate, OwnerKind.IMPLEMENTATION).getJvmMethodSignature(),
typeMapper.mapSetterSignature(overridden.getOriginal(), OwnerKind.IMPLEMENTATION).getJvmMethodSignature());
}
}
}