Don't generate empty constructor if there is secondary one with empty parameter list
This commit is contained in:
@@ -39,8 +39,10 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeDeclarationsPackage;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.JetClass;
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject;
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction;
|
||||
import org.jetbrains.kotlin.psi.JetSecondaryConstructor;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
@@ -789,6 +791,7 @@ public class FunctionCodegen {
|
||||
Visibilities.isPrivate(constructorDescriptor.getVisibility())) return false;
|
||||
|
||||
if (constructorDescriptor.getValueParameters().isEmpty()) return false;
|
||||
if (classOrObject instanceof JetClass && hasSecondaryConstructorsWithNoParameters((JetClass) classOrObject)) return false;
|
||||
|
||||
for (ValueParameterDescriptor parameterDescriptor : constructorDescriptor.getValueParameters()) {
|
||||
if (!parameterDescriptor.declaresDefaultValue()) {
|
||||
@@ -798,6 +801,13 @@ public class FunctionCodegen {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean hasSecondaryConstructorsWithNoParameters(@NotNull JetClass klass) {
|
||||
for (JetSecondaryConstructor constructor : klass.getSecondaryConstructors()) {
|
||||
if (constructor.getValueParameters().isEmpty()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generateBridge(
|
||||
@Nullable PsiElement origin,
|
||||
@NotNull FunctionDescriptor descriptor,
|
||||
|
||||
Reference in New Issue
Block a user