detekt/detekt

Report when a delegation pattern is used to implement interface containing default method

Aperta

#8905 aperta il 5 dic 2025

 (1 commento) (1 reazione) (0 assegnatari)Kotlin (834 fork)batch import
help wantedrules

Metriche repository

Star
 (6942 stelle)
Metriche merge PR
 (Merge medio 4g 9h) (65 PR mergiate in 30 g)

Descrizione

Expected Behavior of the rule

For below file in Java

// FILE: A.java
interface A {
    public int defaultValue() { return 0 }
    public fun void abstractFun()
}
class AImpl : A {
    override fun abstractFun() { /* doing some work */ }
}

class B(a: AImpl): A by a

should be reported by the rule

Context

See discussion https://youtrack.jetbrains.com/issue/KT-15226 and https://discuss.kotlinlang.org/t/collision-between-kotlin-class-delegation-and-java-8-default-methods/1994

One issue found in open source otel android sdk https://github.com/open-telemetry/opentelemetry-android/pull/1464

Guida contributor