Generate bridges for super-calls only when needed
#KT-2887 Fixed
This commit is contained in:
@@ -1747,8 +1747,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
boolean superCall = isSuperCall(call);
|
||||
|
||||
if (superCall && !isInterface(fd.getContainingDeclaration())) {
|
||||
CodegenContext c = getParentContextSubclassOf((ClassDescriptor) fd.getContainingDeclaration());
|
||||
fd = (FunctionDescriptor) c.getAccessor(unwrapFakeOverride(fd));
|
||||
JetSuperExpression expression = getSuperCallExpression(call);
|
||||
ClassDescriptor owner = getSuperCallLabelTarget(expression);
|
||||
CodegenContext c = context.findParentContextWithDescriptor(owner);
|
||||
assert c != null : "Couldn't find a context for a super-call: " + fd;
|
||||
if (c != context.getParentContext()) {
|
||||
fd = (FunctionDescriptor) c.getAccessor(unwrapFakeOverride(fd));
|
||||
}
|
||||
}
|
||||
|
||||
fd = accessableFunctionDescriptor(fd);
|
||||
|
||||
@@ -217,6 +217,16 @@ public abstract class CodegenContext {
|
||||
return cur == null ? null : (ClassDescriptor) cur.getContextDescriptor();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CodegenContext findParentContextWithDescriptor(DeclarationDescriptor descriptor) {
|
||||
CodegenContext c = this;
|
||||
while (c != null) {
|
||||
if (c.getContextDescriptor() == descriptor) break;
|
||||
c = c.getParentContext();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public DeclarationDescriptor getAccessor(DeclarationDescriptor descriptor) {
|
||||
if (accessors == null) {
|
||||
accessors = new HashMap<DeclarationDescriptor, DeclarationDescriptor>();
|
||||
|
||||
Reference in New Issue
Block a user