Skip to content

Commit 38abd38

Browse files
authored
Merge pull request #11045 from tamasvajk/kotlin-confusing-default
Kotlin: Excluded compiler generated methods from `java/confusing-method-signature`
2 parents c82410f + a7cc8fc commit 38abd38

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

java/ql/src/Violations of Best Practice/Naming Conventions/ConfusingOverloading.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ private predicate candidateMethod(RefType t, Method m, string name, int numParam
5757
m.getNumberOfParameters() = numParam and
5858
m = m.getSourceDeclaration() and
5959
not m.getAnAnnotation() instanceof DeprecatedAnnotation and
60+
// Exclude compiler generated methods, such as Kotlin `$default` methods:
61+
not m.isCompilerGenerated() and
6062
not whitelist(name)
6163
}
6264

java/ql/test/kotlin/query-tests/ConfusingMethodSignature/Test.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ class C {
77
prop(this)
88
}
99
}
10+
11+
class A {
12+
fun <T : Any> fn(value: T, i: Int = 1) {}
13+
fun fn(value: String, i: Int = 1) {}
14+
}

0 commit comments

Comments
 (0)