diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java index dd473c62916..1d45811a1dd 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java @@ -84,10 +84,12 @@ public class CallableMethod implements Callable { return signature.getValueParameterTypes(); } + @Nullable public JvmClassName getThisType() { return thisClass; } + @Nullable public Type getReceiverClass() { return receiverParameterType; } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index a397670d869..c93b43e14b5 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1516,6 +1516,7 @@ public class ExpressionCodegen extends JetVisitor { } if (enclosed != context.getThisDescriptor()) { CodegenContext c = context; + //noinspection ConstantConditions while (!(c instanceof CodegenContexts.ClassContext) || !DescriptorUtils.isSubclass(c.getThisDescriptor(), enclosed)) { c = c.getParentContext(); @@ -1720,6 +1721,7 @@ public class ExpressionCodegen extends JetVisitor { } } + @Nullable private static JetExpression getReceiverForSelector(PsiElement expression) { if (expression.getParent() instanceof JetDotQualifiedExpression && !isReceiver(expression)) { final JetDotQualifiedExpression parent = (JetDotQualifiedExpression) expression.getParent(); @@ -1793,9 +1795,11 @@ public class ExpressionCodegen extends JetVisitor { assert cur != null; - if (DescriptorUtils.isSubclass(cur.getThisDescriptor(), calleeContainingClass)) { - if (!isObject || (cur.getThisDescriptor() == calleeContainingClass)) { - return castToRequiredTypeOfInterfaceIfNeeded(result, cur.getThisDescriptor(), calleeContainingClass); + final ClassDescriptor thisDescriptor = cur.getThisDescriptor(); + assert thisDescriptor != null; + if (DescriptorUtils.isSubclass(thisDescriptor, calleeContainingClass)) { + if (!isObject || (thisDescriptor == calleeContainingClass)) { + return castToRequiredTypeOfInterfaceIfNeeded(result, thisDescriptor, calleeContainingClass); } else { v.getstatic(type.getInternalName(), "$instance", type.getDescriptor()); @@ -2447,6 +2451,7 @@ public class ExpressionCodegen extends JetVisitor { v.invokevirtual("java/lang/StringBuilder", "append", appendDescriptor.getDescriptor()); } + @Nullable private static JetSimpleNameExpression targetLabel(JetExpression expression) { if (expression.getParent() instanceof JetPrefixExpression) { JetPrefixExpression parent = (JetPrefixExpression) expression.getParent(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 342bbf8ecad..2e22240c7b5 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -205,6 +205,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } } + @Nullable private static ClassDescriptor getContainingClassDescriptor(ClassDescriptor decl) { DeclarationDescriptor container = decl.getContainingDeclaration(); while (container != null && !(container instanceof NamespaceDescriptor)) { @@ -768,6 +769,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { typeMapper.getClosureAnnotator().getEclosingClassDescriptor(descriptor).getDefaultType(), MapTypeMode.VALUE)); } Method superCallMethod = new Method("", Type.VOID_TYPE, parameterTypes.toArray(new Type[parameterTypes.size()])); + //noinspection ConstantConditions iv.invokespecial(typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName(), "", superCallMethod.getDescriptor()); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index ddaa7cc58f5..6d8e4bc9ddf 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -341,6 +341,7 @@ public class JetTypeMapper { return mapType(jetType, signatureVisitor, MapTypeMode.VALUE); } + @Nullable public static String getLocalNameForObject(JetObjectDeclaration object) { PsiElement parent = object.getParent(); if (parent instanceof JetClassObject) { @@ -596,11 +597,7 @@ public class JetTypeMapper { } } - public CallableMethod mapToCallableMethod(FunctionDescriptor functionDescriptor, boolean superCall, OwnerKind kind) { - if (functionDescriptor == null) { - return null; - } - + public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor functionDescriptor, boolean superCall, OwnerKind kind) { final DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration(); while (functionDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {