Kotlin class inherit from scala abstract class issues


#1

I have an example where recently we needed to subclass akka.persistence.AbstractPersistentActorWithAtLeastOnceDelivery

This abstract class has a few things going on, of which also includes scala traits. I get the following error when trying to compile a kotlin class that inherits from it.

class OurPersistentActor : AbstractPersistentActorWithAtLeastOnceDelivery()

The compile error is…
Error:(53, 1) Kotlin: Class ‘OurPersistentActor’ must be declared abstract or implement abstract base class member public abstract fun akka$persistence$AtLeastOnceDeliveryLike$$unconfirmed_$eq(p0: SortedMap<Any!, Delivery!>!): Unit defined in akka.persistence.AbstractPersistentActorWithAtLeastOnceDelivery

Using this base class from Java compiles fine though.

Relevant base class definition…

Problematic field defined in trait I think


#2

Hello!
Can you tell what Kotlin version and akka dependency do you use?
I’ve just checked with 1.1.2 and

        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-persistence-experimental_2.11</artifactId>
            <version>2.3.13</version>
        </dependency>

The following code got compiled successfully

class OurPersistentActor : AbstractPersistentActorWithAtLeastOnceDelivery() {
    override fun receiveCommand(): PartialFunction<Any, BoxedUnit> {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun receiveRecover(): PartialFunction<Any, BoxedUnit> {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
}

#3

Sorry should have been more specific. I’ve tried both Kotlin 1.1.1 as well as 1.1.2 with no differences. The version of akka that we are using is 2.5.1.
akka_version = '2.5.1’
compile "com.typesafe.akka:akka-actor_2.12:$akka_version"
compile "com.typesafe.akka:akka-cluster-tools_2.12:$akka_version"
compile "com.typesafe.akka:akka-cluster-sharding_2.12:$akka_version"
compile "com.typesafe.akka:akka-persistence_2.12:$akka_version"
compile “com.typesafe.akka:akka-persistence-query_2.12:$akka_version”


#4

@denis.zharkov is there something more I can provide to help demonstrate the problem? Would you like me to post a repo to reproduce the problem?


#5

It looks like a bug in scala compiler that probably can be solved in some sense on the side of Kotlin too (see the issue)


#6

BTW, could you please try 2.11 postfix for scalac version?


#7

That worked great. Good find… and thanks for the help.