1

I've defined the following extension function

fun <T> T.showAppPresentation(
    appPresentable: Maybe<AppPresentable>,
    appPresentationView: AppPresentationView,
    closeListener: () -> Unit
) where T : Fragment, T : FragmentPresentable {
    TODO()
}

where Fragment is an android Fragment and FragmentPresentable is an interface. It shows no error in Android Studio. When I try to compile my code, I got the following errors:

FragmentPresentableExtensionsKt.java:12: error: <identifier> expected
    public static final <T extends androidx.fragment.app.Fragment & FragmentPresentable>void showAppPresentation(@org.jetbrains.annotations.NotNull()
                                                                    ^
FragmentPresentableExtensionsKt.java:12: error: illegal start of type
    public static final <T extends androidx.fragment.app.Fragment & FragmentPresentable>void showAppPresentation(@org.jetbrains.annotations.NotNull()
                                                                                      ^
FragmentPresentableExtensionsKt.java:12: error: '(' expected
    public static final <T extends androidx.fragment.app.Fragment & FragmentPresentable>void showAppPresentation(@org.jetbrains.annotations.NotNull()
                                                                                       ^

What am I missing?

Benjamin
  • 7,055
  • 6
  • 40
  • 60
  • The error message was initially formatted as a quote (using `>`), I edited to use a code block, so that it respects the spaces and indentation (which is important in this error). Could you please re-paste your initial error message in the code block to realign the text faithfully? – Joffrey Jun 09 '21 at 11:13
  • As a side note, any reason to use `Maybe` instead of nullable type? – Joffrey Jun 09 '21 at 11:13
  • @Joffrey My indention is no better than the one you already did. As for the `Maybe` the data comes from Rx which does not accept nullable type. – Benjamin Jun 09 '21 at 11:25
  • thanks for your reply. This is weird. Please scroll to the right. You're saying the arrows of the error messages really point to the second "p" of `showAppPresentation` and the second "t" of `showAppPresentation` respectively? Also there really is no space between `>` and `void`? – Joffrey Jun 09 '21 at 13:43
  • @Joffrey Fixed. All the arrows are more or less pointing to `FragmentPresentable`. – Benjamin Jun 09 '21 at 15:20

1 Answers1

0

I found the solution: FragmentPresentable was inside a package named interface which is a keyword in java/kotlin. It caused the issue at compile time. I moved FragmentPresentable inside a package view and now everything is working as expected.

Benjamin
  • 7,055
  • 6
  • 40
  • 60