0
votes

I am trying to subclass a function ActionableNotification.java which reads similar to this:

package com.venmo.notifications.notifications;

import android.content.ContextWrapper;
import com.squareup.picasso.Target;

public abstract class ActionableNotification extends ContextWrapper implements Target {

    @NonNull
    protected abstract String getTrackingNotificationCategory();
    // ...
}

The inheriting class reads similar to this

class DeclineInsufficientFundsBalanceOnlyCardNotification(context : Context, intent : Intent) : ActionableNotification(context, intent) {

    override fun getTrackingNotificationCategory() = ""
    // ...
 }

However, when I try to compile I get this error:

/Users/kupeek/dev/venmo-android/p2p-app/src/main/java/com/venmo/notifications/notifications/DeclineInsufficientFundsBalanceOnlyCardNotification.kt: (21, 53): Return type of 'getTrackingNotificationCategory' is not a subtype of the return type of the overridden member '@NonNull protected/protected and package/ abstract fun getTrackingNotificationCategory(): String defined in com.venmo.notifications.notifications.ActionableNotification'

I don't understand this error message, because the return type of the Kotlin inheriting class is a string, as is the base class?

2
Can you share a screenshot of the error and where it appears in the editing window?TheWanderer

2 Answers

1
votes

Maybe annotating the abstract method with the JetBrains annotation @NotNull will be better. I found it taking a look a this. Hope this may help you.

0
votes

Although I'm not entirely sure why this worked, the error went away when I specified the String type for the overriding function, instead of relying on type inference:

override fun getTrackingNotificationCategory(): String = ""