Duplicated JetTypeMapper.mapSignature removed
This commit is contained in:
@@ -170,7 +170,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
JetExpression fun,
|
||||
ClassBuilder cv
|
||||
) {
|
||||
Method bridge = typeMapper.mapSignature(interfaceFunction.getName(), interfaceFunction).getAsmMethod();
|
||||
Method bridge = typeMapper.mapSignature(interfaceFunction).getAsmMethod();
|
||||
|
||||
Method delegate = typeMapper.mapSignature(interfaceFunction.getName(), funDescriptor).getAsmMethod();
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
Method method =
|
||||
state.getTypeMapper().mapSignature(functionDescriptor.getName(), functionDescriptor).getAsmMethod();
|
||||
state.getTypeMapper().mapSignature(functionDescriptor).getAsmMethod();
|
||||
|
||||
Queue<FunctionDescriptor> bfsQueue = new LinkedList<FunctionDescriptor>();
|
||||
Set<FunctionDescriptor> visited = new HashSet<FunctionDescriptor>();
|
||||
@@ -413,7 +413,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
FunctionDescriptor descriptor = bfsQueue.poll();
|
||||
if (descriptor.getKind() == CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
Method overridden =
|
||||
state.getTypeMapper().mapSignature(descriptor.getName(), descriptor.getOriginal()).getAsmMethod();
|
||||
state.getTypeMapper().mapSignature(descriptor.getOriginal()).getAsmMethod();
|
||||
if (differentMethods(method, overridden)) {
|
||||
bridgesToGenerate.add(overridden);
|
||||
}
|
||||
@@ -788,8 +788,8 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
public void genDelegate(FunctionDescriptor functionDescriptor, FunctionDescriptor overriddenDescriptor, StackValue field) {
|
||||
genDelegate(functionDescriptor, (ClassDescriptor) overriddenDescriptor.getContainingDeclaration(), field,
|
||||
typeMapper.mapSignature(functionDescriptor.getName(), functionDescriptor),
|
||||
typeMapper.mapSignature(overriddenDescriptor.getName(), overriddenDescriptor.getOriginal())
|
||||
typeMapper.mapSignature(functionDescriptor),
|
||||
typeMapper.mapSignature(overriddenDescriptor.getOriginal())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
FunctionDescriptor function = DescriptorUtils.getParentOfType(descriptor, FunctionDescriptor.class);
|
||||
|
||||
if (function != null) {
|
||||
Method method = typeMapper.mapSignature(function.getName(), function).getAsmMethod();
|
||||
Method method = typeMapper.mapSignature(function).getAsmMethod();
|
||||
v.visitOuterClass(outerClassName, method.getName(), method.getDescriptor());
|
||||
}
|
||||
else {
|
||||
@@ -678,7 +678,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
assert returnType != null : "Return type of component function should not be null: " + function;
|
||||
final Type componentType = typeMapper.mapReturnType(returnType);
|
||||
|
||||
JvmMethodSignature signature = typeMapper.mapSignature(function.getName(), function);
|
||||
JvmMethodSignature signature = typeMapper.mapSignature(function);
|
||||
|
||||
FunctionCodegen fc = new FunctionCodegen(context, v, state);
|
||||
fc.generateMethod(myClass, signature, true, null, function, new FunctionGenerationStrategy() {
|
||||
@@ -701,7 +701,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateCopyFunction(@NotNull final FunctionDescriptor function) {
|
||||
JvmMethodSignature methodSignature = typeMapper.mapSignature(function.getName(), function);
|
||||
JvmMethodSignature methodSignature = typeMapper.mapSignature(function);
|
||||
|
||||
final Type thisDescriptorType = typeMapper.mapType(descriptor.getDefaultType());
|
||||
|
||||
@@ -811,11 +811,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
FunctionDescriptor bridge = (FunctionDescriptor) entry.getValue();
|
||||
FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
|
||||
|
||||
Method method = typeMapper.mapSignature(bridge.getName(), bridge).getAsmMethod();
|
||||
Method method = typeMapper.mapSignature(bridge).getAsmMethod();
|
||||
boolean isConstructor = original instanceof ConstructorDescriptor;
|
||||
Method originalMethod = isConstructor ?
|
||||
typeMapper.mapToCallableMethod((ConstructorDescriptor) original).getSignature().getAsmMethod() :
|
||||
typeMapper.mapSignature(original.getName(), original).getAsmMethod();
|
||||
typeMapper.mapSignature(original).getAsmMethod();
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
|
||||
String owner = typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION, isCallInsideSameModuleAsDeclared(original, context)).getInternalName();
|
||||
@@ -1414,8 +1414,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Method function = typeMapper.mapSignature(fun.getName(), fun).getAsmMethod();
|
||||
Method functionOriginal = typeMapper.mapSignature(fun.getName(), fun.getOriginal()).getAsmMethod();
|
||||
Method function = typeMapper.mapSignature(fun).getAsmMethod();
|
||||
Method functionOriginal = typeMapper.mapSignature(fun.getOriginal()).getAsmMethod();
|
||||
return new TraitImplDelegateInfo(function, functionOriginal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,7 +568,33 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
}
|
||||
|
||||
private JvmMethodSignature mapSignature(FunctionDescriptor f, boolean needGenericSignature, OwnerKind kind) {
|
||||
@NotNull
|
||||
private JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, boolean needGenericSignature, @NotNull OwnerKind kind) {
|
||||
String name = f.getName().getName();
|
||||
if (f instanceof PropertyAccessorDescriptor) {
|
||||
boolean isGetter = f instanceof PropertyGetterDescriptor;
|
||||
name = getPropertyAccessorName(((PropertyAccessorDescriptor) f).getCorrespondingProperty(), isGetter);
|
||||
}
|
||||
return mapSignature(name, f, needGenericSignature, kind);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmMethodSignature mapSignature(@NotNull Name functionName, @NotNull FunctionDescriptor f) {
|
||||
return mapSignature(functionName.getName(), f, false, OwnerKind.IMPLEMENTATION);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f) {
|
||||
return mapSignature(f.getName(), f);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JvmMethodSignature mapSignature(
|
||||
@NotNull String methodName,
|
||||
@NotNull FunctionDescriptor f,
|
||||
boolean needGenericSignature,
|
||||
@NotNull OwnerKind kind
|
||||
) {
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
needGenericSignature = false;
|
||||
}
|
||||
@@ -598,12 +624,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
signatureVisitor.writeReturnTypeEnd();
|
||||
}
|
||||
|
||||
String name = f.getName().getName();
|
||||
if (f instanceof PropertyAccessorDescriptor) {
|
||||
boolean isGetter = f instanceof PropertyGetterDescriptor;
|
||||
name = getPropertyAccessorName(((PropertyAccessorDescriptor)f).getCorrespondingProperty(), isGetter);
|
||||
}
|
||||
return signatureVisitor.makeJvmMethodSignature(name);
|
||||
return signatureVisitor.makeJvmMethodSignature(methodName);
|
||||
}
|
||||
|
||||
private void writeThisIfNeeded(
|
||||
@@ -687,33 +708,6 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
signatureVisitor.writeFormalTypeParameterEnd();
|
||||
}
|
||||
|
||||
public JvmMethodSignature mapSignature(Name name, FunctionDescriptor f) {
|
||||
ReceiverParameterDescriptor receiver = f.getReceiverParameter();
|
||||
|
||||
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, false);
|
||||
|
||||
writeFormalTypeParameters(f.getTypeParameters(), signatureWriter);
|
||||
|
||||
signatureWriter.writeParametersStart();
|
||||
|
||||
writeThisForAccessorIfNeeded(f, signatureWriter);
|
||||
|
||||
List<ValueParameterDescriptor> parameters = f.getValueParameters();
|
||||
writeReceiverIfNeeded(receiver, signatureWriter);
|
||||
for (ValueParameterDescriptor parameter : parameters) {
|
||||
writeParameter(signatureWriter, parameter.getType());
|
||||
}
|
||||
|
||||
signatureWriter.writeParametersEnd();
|
||||
|
||||
signatureWriter.writeReturnType();
|
||||
JetType returnType = f.getReturnType();
|
||||
assert returnType != null;
|
||||
mapReturnType(returnType, signatureWriter);
|
||||
signatureWriter.writeReturnTypeEnd();
|
||||
|
||||
return signatureWriter.makeJvmMethodSignature(name.getName());
|
||||
}
|
||||
|
||||
private void writeReceiverIfNeeded(@Nullable ReceiverParameterDescriptor receiver, BothSignatureWriter signatureWriter) {
|
||||
if (receiver != null) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
open class Base {
|
||||
val pr : String = "OK"
|
||||
}
|
||||
|
||||
trait Trait : Base {
|
||||
fun f() : String {
|
||||
return this.pr
|
||||
}
|
||||
}
|
||||
|
||||
class A : Trait, Base() {
|
||||
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return if (A().f() == A().pr) "OK" else "fail"
|
||||
}
|
||||
@@ -3138,6 +3138,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/properties/kt613.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("traitExtendsClass.kt")
|
||||
public void testTraitExtendsClass() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/properties/traitExtendsClass.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/safeCall")
|
||||
|
||||
Reference in New Issue
Block a user