I define two objects:

  1. data class ParserK annotated with @higherkind
  2. interface ParserKFunctor annotated with @extension

Here is the code:

data class ParserK<A>(val f: (String) -> Option<A>): ParserKOf<A> {
    companion object

interface ParserKFunctor : Functor<ForParserK> {
    override fun <A, B> Kind<ForParserK, A>.map(f: (A) -> B): Kind<ForParserK, B> {

When I execute ./gradlew :app:kaptKotlin I get:

error: "Arrow's annotations can only be used on Kotlin classes". Not valid for error.NonExistentClass

> Task :app:kaptGenerateStubsKotlin

> Task :app:kaptKotlin FAILED
e: error: Arrow's annotations can only be used on Kotlin classes. Not valid for error.NonExistentClass                                           

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptKotlin'.
> Compilation error. See log for more details

Here is what I discovered:

  1. If I remove the functor definition then the goal completes successfully and I can see the generated code.
  2. If I remove @higherkind from the data class ParserK and copy the generated sources into the same file where ParserK is defined then I can see the generated code for the functor.

It seems like a bug for me, correct me if I am wrong, please


Here is the link to the repository with my code: repository

0 Answers