use of org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature in project kotlin by JetBrains.
the class KotlinTypeMapper method writeSuperConstructorCallParameters.
private void writeSuperConstructorCallParameters(@NotNull JvmSignatureWriter sw, @NotNull ClassConstructorDescriptor descriptor, @NotNull ResolvedCall<ConstructorDescriptor> superCall, boolean hasOuter) {
ConstructorDescriptor superDescriptor = SamCodegenUtil.resolveSamAdapter(superCall.getResultingDescriptor());
List<ResolvedValueArgument> valueArguments = superCall.getValueArgumentsByIndex();
assert valueArguments != null : "Failed to arrange value arguments by index: " + superDescriptor;
List<JvmMethodParameterSignature> parameters = mapSignatureSkipGeneric(superDescriptor.getOriginal()).getValueParameters();
int params = parameters.size();
int args = valueArguments.size();
// Mapped parameters should consist of captured values plus all of valueArguments
assert params >= args : String.format("Incorrect number of mapped parameters vs arguments: %d < %d for %s", params, args, descriptor);
// Include all captured values, i.e. those parameters for which there are no resolved value arguments
for (int i = 0; i < params - args; i++) {
JvmMethodParameterSignature parameter = parameters.get(i);
JvmMethodParameterKind kind = parameter.getKind();
if (kind == JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL)
continue;
if (hasOuter && kind == JvmMethodParameterKind.OUTER)
continue;
writeParameter(sw, JvmMethodParameterKind.SUPER_CALL_PARAM, parameter.getAsmType());
}
if (isAnonymousObject(descriptor.getContainingDeclaration())) {
// For anonymous objects, also add all real non-default value arguments passed to the super constructor
for (int i = 0; i < args; i++) {
ResolvedValueArgument valueArgument = valueArguments.get(i);
JvmMethodParameterSignature parameter = parameters.get(params - args + i);
if (!(valueArgument instanceof DefaultValueArgument)) {
writeParameter(sw, JvmMethodParameterKind.SUPER_CALL_PARAM, parameter.getAsmType());
}
}
}
}
Aggregations