Minor. Pass callableDescriptor into writeParameter

This commit is contained in:
Denis Zharkov
2015-11-27 11:48:50 +03:00
parent 406e31f54a
commit 0255be7deb
@@ -970,7 +970,7 @@ public class JetTypeMapper {
writeAdditionalConstructorParameters((ConstructorDescriptor) f, sw); writeAdditionalConstructorParameters((ConstructorDescriptor) f, sw);
for (ValueParameterDescriptor parameter : valueParameters) { for (ValueParameterDescriptor parameter : valueParameters) {
writeParameter(sw, parameter.getType()); writeParameter(sw, parameter.getType(), f);
} }
if (f instanceof AccessorForConstructorDescriptor) { if (f instanceof AccessorForConstructorDescriptor) {
@@ -987,12 +987,12 @@ public class JetTypeMapper {
ReceiverParameterDescriptor receiverParameter = f.getExtensionReceiverParameter(); ReceiverParameterDescriptor receiverParameter = f.getExtensionReceiverParameter();
if (receiverParameter != null) { if (receiverParameter != null) {
writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.getType()); writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.getType(), f);
} }
for (ValueParameterDescriptor parameter : valueParameters) { for (ValueParameterDescriptor parameter : valueParameters) {
if (writeCustomParameter(f, parameter, sw)) continue; if (writeCustomParameter(f, parameter, sw)) continue;
writeParameter(sw, parameter.getType()); writeParameter(sw, parameter.getType(), f);
} }
sw.writeReturnType(); sw.writeReturnType();
@@ -1025,7 +1025,7 @@ public class JetTypeMapper {
if (SpecialBuiltinMembers.isFromJavaOrBuiltins(f)) return false; if (SpecialBuiltinMembers.isFromJavaOrBuiltins(f)) return false;
if (overridden.getName().asString().equals("remove") && mapType(parameter.getType()).getSort() == Type.INT) { if (overridden.getName().asString().equals("remove") && mapType(parameter.getType()).getSort() == Type.INT) {
writeParameter(sw, TypeUtils.makeNullable(parameter.getType())); writeParameter(sw, TypeUtils.makeNullable(parameter.getType()), f);
return true; return true;
} }
@@ -1118,7 +1118,7 @@ public class JetTypeMapper {
} }
else return; else return;
writeParameter(sw, JvmMethodParameterKind.THIS, thisType.getDefaultType()); writeParameter(sw, JvmMethodParameterKind.THIS, thisType.getDefaultType(), descriptor);
} }
@NotNull @NotNull
@@ -1185,11 +1185,20 @@ public class JetTypeMapper {
} }
} }
private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull KotlinType type) { private void writeParameter(
writeParameter(sw, JvmMethodParameterKind.VALUE, type); @NotNull BothSignatureWriter sw,
@NotNull KotlinType type,
@NotNull CallableDescriptor callableDescriptor
) {
writeParameter(sw, JvmMethodParameterKind.VALUE, type, callableDescriptor);
} }
private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull JvmMethodParameterKind kind, @NotNull KotlinType type) { private void writeParameter(
@NotNull BothSignatureWriter sw,
@NotNull JvmMethodParameterKind kind,
@NotNull KotlinType type,
@NotNull CallableDescriptor callableDescriptor
) {
sw.writeParameterType(kind); sw.writeParameterType(kind);
mapType(type, sw, TypeMappingMode.getOptimalModeForValueParameter(type)); mapType(type, sw, TypeMappingMode.getOptimalModeForValueParameter(type));
sw.writeParameterTypeEnd(); sw.writeParameterTypeEnd();
@@ -1206,18 +1215,20 @@ public class JetTypeMapper {
ClassDescriptor captureThis = getDispatchReceiverParameterForConstructorCall(descriptor, closure); ClassDescriptor captureThis = getDispatchReceiverParameterForConstructorCall(descriptor, closure);
if (captureThis != null) { if (captureThis != null) {
writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType()); writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType(), descriptor);
} }
KotlinType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null; KotlinType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null;
if (captureReceiverType != null) { if (captureReceiverType != null) {
writeParameter(sw, JvmMethodParameterKind.RECEIVER, captureReceiverType); writeParameter(sw, JvmMethodParameterKind.RECEIVER, captureReceiverType, descriptor);
} }
ClassDescriptor containingDeclaration = descriptor.getContainingDeclaration(); ClassDescriptor containingDeclaration = descriptor.getContainingDeclaration();
if (containingDeclaration.getKind() == ClassKind.ENUM_CLASS || containingDeclaration.getKind() == ClassKind.ENUM_ENTRY) { if (containingDeclaration.getKind() == ClassKind.ENUM_CLASS || containingDeclaration.getKind() == ClassKind.ENUM_ENTRY) {
writeParameter(sw, JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL, DescriptorUtilsKt.getBuiltIns(descriptor).getStringType()); writeParameter(
writeParameter(sw, JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL, DescriptorUtilsKt.getBuiltIns(descriptor).getIntType()); sw, JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL, DescriptorUtilsKt.getBuiltIns(descriptor).getStringType(), descriptor);
writeParameter(
sw, JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL, DescriptorUtilsKt.getBuiltIns(descriptor).getIntType(), descriptor);
} }
if (closure == null) return; if (closure == null) return;
@@ -1313,11 +1324,11 @@ public class JetTypeMapper {
sw.writeParametersStart(); sw.writeParametersStart();
for (ScriptDescriptor importedScript : importedScripts) { for (ScriptDescriptor importedScript : importedScripts) {
writeParameter(sw, importedScript.getDefaultType()); writeParameter(sw, importedScript.getDefaultType(), script.getUnsubstitutedPrimaryConstructor());
} }
for (ValueParameterDescriptor valueParameter : script.getUnsubstitutedPrimaryConstructor().getValueParameters()) { for (ValueParameterDescriptor valueParameter : script.getUnsubstitutedPrimaryConstructor().getValueParameters()) {
writeParameter(sw, valueParameter.getType()); writeParameter(sw, valueParameter.getType(), script.getUnsubstitutedPrimaryConstructor());
} }
writeVoidReturn(sw); writeVoidReturn(sw);