I have an interface ILoginExt with an extension function Login.logout(). This interface is implemented by the class LoginExt, and another class Login delegates ILoginExt to LoginExt. While I can call the logout extension function within the Login class, trying to call it from an instance of Login in the main function results in an “Unresolved reference: logout” error.
Please find the program below
fun main() {
val login = Login()
login.login()
login.callLogOut()
//Trying to call logout extension function. But received Unresolved reference 'logout' error.
login.logout()
}
class Login: ILoginExt by LoginExt() {
fun callLogOut() {
logout() //Extension function can call from Login
}
}
interface ILoginExt {
fun login() {
println("ILoginExt -> login() called")
}
fun Login.logout() {
println("ILoginExt -> login() called")
}
}
class LoginExt() : ILoginExt
0