Delete unreachable code in ImplementationBodyCodegen
Change superCall type to JetDelegatorToSuperCall
This commit is contained in:
@@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.backend.common.CodegenUtil;
|
import org.jetbrains.jet.backend.common.CodegenUtil;
|
||||||
import org.jetbrains.jet.backend.common.DataClassMethodGenerator;
|
import org.jetbrains.jet.backend.common.DataClassMethodGenerator;
|
||||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
|
||||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||||
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
|
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
|
||||||
import org.jetbrains.jet.codegen.context.ClassContext;
|
import org.jetbrains.jet.codegen.context.ClassContext;
|
||||||
@@ -85,7 +84,7 @@ import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
|||||||
|
|
||||||
public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||||
private static final String VALUES = "$VALUES";
|
private static final String VALUES = "$VALUES";
|
||||||
private JetDelegationSpecifier superCall;
|
private JetDelegatorToSuperCall superCall;
|
||||||
private Type superClassAsmType;
|
private Type superClassAsmType;
|
||||||
@Nullable // null means java/lang/Object
|
@Nullable // null means java/lang/Object
|
||||||
private JetType superClassType;
|
private JetType superClassType;
|
||||||
@@ -399,7 +398,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (JetDelegationSpecifier specifier : delegationSpecifiers) {
|
for (JetDelegationSpecifier specifier : delegationSpecifiers) {
|
||||||
if (specifier instanceof JetDelegatorToSuperClass || specifier instanceof JetDelegatorToSuperCall) {
|
if (specifier instanceof JetDelegatorToSuperCall) {
|
||||||
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
assert superType != null :
|
assert superType != null :
|
||||||
String.format("No type recorded for \n---\n%s\n---\n", JetPsiUtil.getElementTextWithContext(specifier));
|
String.format("No type recorded for \n---\n%s\n---\n", JetPsiUtil.getElementTextWithContext(specifier));
|
||||||
@@ -411,7 +410,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (!isInterface(superClassDescriptor)) {
|
if (!isInterface(superClassDescriptor)) {
|
||||||
superClassType = superType;
|
superClassType = superType;
|
||||||
superClassAsmType = typeMapper.mapClass(superClassDescriptor);
|
superClassAsmType = typeMapper.mapClass(superClassDescriptor);
|
||||||
superCall = specifier;
|
superCall = (JetDelegatorToSuperCall) specifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1194,9 +1193,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (superCall == null) {
|
if (superCall == null) {
|
||||||
genSimpleSuperCall(iv);
|
genSimpleSuperCall(iv);
|
||||||
}
|
}
|
||||||
else if (superCall instanceof JetDelegatorToSuperClass) {
|
|
||||||
genSuperCallToDelegatorToSuperClass(iv);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor);
|
generateDelegatorToConstructorCall(iv, codegen, constructorDescriptor);
|
||||||
}
|
}
|
||||||
@@ -1249,23 +1245,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.visitInsn(RETURN);
|
iv.visitInsn(RETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void genSuperCallToDelegatorToSuperClass(InstructionAdapter iv) {
|
|
||||||
iv.load(0, superClassAsmType);
|
|
||||||
JetType superType = bindingContext.get(BindingContext.TYPE, superCall.getTypeReference());
|
|
||||||
List<Type> parameterTypes = new ArrayList<Type>();
|
|
||||||
assert superType != null;
|
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
|
||||||
if (CodegenBinding.hasThis0(bindingContext, superClassDescriptor)) {
|
|
||||||
iv.load(1, OBJECT_TYPE);
|
|
||||||
parameterTypes.add(typeMapper.mapType(
|
|
||||||
enclosingClassDescriptor(bindingContext, descriptor)));
|
|
||||||
}
|
|
||||||
Method superCallMethod = new Method("<init>", Type.VOID_TYPE, parameterTypes.toArray(new Type[parameterTypes.size()]));
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
iv.invokespecial(typeMapper.mapType(superClassDescriptor).getInternalName(), "<init>",
|
|
||||||
superCallMethod.getDescriptor());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void genSimpleSuperCall(InstructionAdapter iv) {
|
private void genSimpleSuperCall(InstructionAdapter iv) {
|
||||||
iv.load(0, superClassAsmType);
|
iv.load(0, superClassAsmType);
|
||||||
if (descriptor.getKind() == ClassKind.ENUM_CLASS || descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
if (descriptor.getKind() == ClassKind.ENUM_CLASS || descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||||
@@ -1452,8 +1431,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (superCall instanceof JetDelegatorToSuperCall && !isAnonymousObject(descriptor)) {
|
if (superCall != null && !isAnonymousObject(descriptor)) {
|
||||||
JetValueArgumentList argumentList = ((JetDelegatorToSuperCall) superCall).getValueArgumentList();
|
JetValueArgumentList argumentList = superCall.getValueArgumentList();
|
||||||
if (argumentList != null) {
|
if (argumentList != null) {
|
||||||
argumentList.accept(visitor);
|
argumentList.accept(visitor);
|
||||||
}
|
}
|
||||||
@@ -1588,7 +1567,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArgumentGenerator argumentGenerator;
|
ArgumentGenerator argumentGenerator;
|
||||||
if (isAnonymousObject(descriptor) && superCall instanceof JetDelegatorToSuperCall) {
|
if (isAnonymousObject(descriptor)) {
|
||||||
List<JvmMethodParameterSignature> superValues = superParameters.subList(superIndex, superParameters.size());
|
List<JvmMethodParameterSignature> superValues = superParameters.subList(superIndex, superParameters.size());
|
||||||
argumentGenerator = new ObjectSuperCallArgumentGenerator(superValues, iv, offset);
|
argumentGenerator = new ObjectSuperCallArgumentGenerator(superValues, iv, offset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,12 +320,6 @@ public class CodegenBinding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasThis0(BindingContext bindingContext, ClassDescriptor classDescriptor) {
|
|
||||||
//noinspection SuspiciousMethodCalls
|
|
||||||
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
|
|
||||||
return closure != null && closure.getCaptureThis() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ResolvedCall<ConstructorDescriptor> findSuperCall(
|
private static ResolvedCall<ConstructorDescriptor> findSuperCall(
|
||||||
@NotNull BindingContext bindingContext,
|
@NotNull BindingContext bindingContext,
|
||||||
|
|||||||
Reference in New Issue
Block a user