https://kotlinlang.org logo
#kapt
Title
y

yigit

02/13/2018, 9:17 PM
is there a way to discover if an interface method has a default implementation ? in java the function has a flag we can check. but in kotlin we don't get that information (java backwards compatibility i guess). we have a possible hack but rather not use it if there is a proper way:
Copy code
val parent = this.enclosingElement as TypeElement
    val innerClass = parent.enclosedElements.find {
        it.kind == ElementKind.CLASS && it.simpleName.contentEquals(org.jetbrains.kotlin.load.java.JvmAbi.DEFAULT_IMPLS_CLASS_NAME)
    } ?: return null
    return innerClass.enclosedElements.find {
        it.kind == ElementKind.METHOD && it.simpleName == this.simpleName
                && paramsMatch(MoreElements.asExecutable(this).parameters,
                MoreElements.asExecutable(it).parameters)
    }