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

WRONG_OVERLOADING_FUNCTION_ARGUMENTS triggers with visibility differences #1505

Closed
jgberry opened this issue Aug 20, 2022 · 3 comments · Fixed by #1520
Closed

WRONG_OVERLOADING_FUNCTION_ARGUMENTS triggers with visibility differences #1505

jgberry opened this issue Aug 20, 2022 · 3 comments · Fixed by #1520
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jgberry
Copy link

jgberry commented Aug 20, 2022

Describe the bug

WRONG_OVERLOADING_FUNCTION_ARGUMENTS is triggered even if the functions have differing visibility and/or modifiers (abstract, suspend, etc.)

Example with different visibility:

public fun doStuff() {
    doStuff(1)
}

private fun doStuff(x: Int) {
    println(x)
}

Example with inline:

public fun doStuff() {
    doStuff(1)
}

public inline fun doStuff(x: Int) {
    println(x)
}

Expected behavior

WRONG_OVERLOADING_FUNCTION_ARGUMENTS should only trigger if the function have identical visibility and identical modifiers.

Observed behavior

WRONG_OVERLOADING_FUNCTION_ARGUMENTS ignores function visibility and modifiers.

Steps to Reproduce

See above examples.

Environment information

  • diktat version: 1.2.3
  • build tool (maven/gradle): gradle
  • how is diktat run (CLI, plugin, etc.): ./gradlew diktatCheck
  • kotlin version: 1.7.10
  • operating system: Ubuntu
  • link to a project (if your project is public):
@jgberry jgberry added the bug Something isn't working label Aug 20, 2022
@orchestr7
Copy link
Member

Hello! thank you for your report, yes, definitely a bug - should be fixed

@orchestr7 orchestr7 self-assigned this Sep 12, 2022
@orchestr7
Copy link
Member

orchestr7 commented Sep 12, 2022

I am even surprised that we are so smart that we have such inspection 😄
Also interesting bug:

We don't handle the following case:

       fun foo(a: Double) {}
       fun foo(a: Double, b: Int) {}

@orchestr7
Copy link
Member

@jgberry thank you for your ideas, we fixed it and will take it to the next release

@0x6675636b796f75676974687562 0x6675636b796f75676974687562 added this to the 1.2.4 milestone Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants