Reputation: 541
//Child class
class DialogPermission(myContext : Context) : BaseDialog(myContext) {
private var mBtnPermission: Button? = null
private var mOnClickListener: DialogInterface.OnClickListener? = null
override fun setWidthScale(): Float {
return 0.9f
}
// parent class
abstract class BaseDialog(protected var context: Context) :
Dialog(context, R.style.DialogTransparent) {...
// error of parent class
Accidental override: The following declarations have the same JVM signature (getContext()Landroid/content/Context;):
public final fun `<get-context>`(): Context? defined in com.applock.lock.widget.BaseDialog
public final fun getContext(): Context defined in com.applock.lock.widget.BaseDialog
// error of child class in kotlin
Inherited platform declarations clash: The following declarations have the same JVM signature (getContext()Landroid/content/Context;): fun `<get-context>`(): Context? defined in com.applock.lock.widget.DialogPermission fun getContext(): Context defined in com.applock.lock.widget.DialogPermission
Upvotes: -1
Views: 91
Reputation: 6160
Since the method getContext()
is final in the Dialog
class, then you cannot override it in subclasses (BaseDialog
in your case).
To figure this out, you can for instance define BaseDialog
as:
abstract class BaseDialog(context: Context) :
Dialog(context, R.style.PreferenceThemeOverlay) {
...
}
Upvotes: 2