Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.3.0] Constructor overloads are incorrectly formatted #2690

Closed
Bencodes opened this issue Jun 5, 2024 · 1 comment · Fixed by #2717
Closed

[1.3.0] Constructor overloads are incorrectly formatted #2690

Bencodes opened this issue Jun 5, 2024 · 1 comment · Fixed by #2717
Milestone

Comments

@Bencodes
Copy link

Bencodes commented Jun 5, 2024

Expected Behavior

KtLint should retain the top level constructor () when an overloaded constructor exists and calls this()

Observed Behavior

KtLint removes the default empty class level constructor when a secondary overloaded constructor exists.

Steps to Reproduce

Given:

class Foo() {
    constructor(foo: String) : this() {
        // N/A
    }
}

KtLint produces the following Kotlin class where the default class level constructor is removed which breaks the overloaded constructors ability to call this()

class Foo {
    constructor(foo: String) : this() {
        // N/A
    }
}

Your Environment

  • Version of ktlint used: 1.3.0
  • Relevant parts of the .editorconfig settings: I'm able to reproduce with an empty editor config.
@paul-dingemans
Copy link
Collaborator

Nice find. An empty VALUE_PARAMETER_LIST should only be disallowed in case the class does not contain a secondary constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants