I'm trying to build and run a project using Akka and Scala 3+ but I encounter a lot of errors.
My build.sbt looks like
name := "akka"
version := "0.1"
scalaVersion := "3.1.1-RC1"
// https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor-typed
libraryDependencies += "com.typesafe.akka" %% "akka-actor-typed" % "2.6.17"
And my sample code
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.actor.Props
class HelloActor extends Actor {
def receive = {
case "hello" => println("hello back at you")
case _ => println("huh?")
}
}
object Main extends App {
val system = ActorSystem("HelloSystem")
// default Actor constructor
val helloActor = system.actorOf(Props[HelloActor], name = "helloactor")
helloActor ! "hello"
helloActor ! "buenos dias"
}
I got a lot of errors in the console
[error] error while loading package$,
[error] class file akka/actor/package.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
[error] TASTy signature has wrong version.
[error] expected: {majorVersion: 28, minorVersion: 1}
[error] found : {majorVersion: 28, minorVersion: 2 [unstable release: 1]}
[error]
[error] This TASTy file was produced by an unstable release.
[error] To read this TASTy file, your tooling must be at the same version.
[error] The TASTy file was produced by Scala 3.1.1-RC1-bin-20211007-c041327-NIGHTLY-git-c041327.
[error] error while loading Actor,
[error] class file akka/actor/Actor.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
[error] TASTy signature has wrong version.
[error] expected: {majorVersion: 28, minorVersion: 1}
[error] found : {majorVersion: 28, minorVersion: 2 [unstable release: 1]}
[error]
[error] This TASTy file was produced by an unstable release.
[error] To read this TASTy file, your tooling must be at the same version.
[error] The TASTy file was produced by Scala 3.1.1-RC1-bin-20211007-c041327-NIGHTLY-git-c041327.
[error] -- [E006] Not Found Error: /Users/andreacappelletti/Downloads/akka/src/main/scala/Main.scala:6:25
[error] 6 |class HelloActor extends Actor {
[error] | ^^^^^
[error] | Not found: type Actor
[error] -- [E081] Type Error: /Users/andreacappelletti/Downloads/akka/src/main/scala/Main.scala:8:4
[error] 8 | case "hello" => println("hello back at you")
[error] | ^
[error] | Missing parameter type
[error] |
[error] | I could not infer the type of the parameter x$1 of expanded function:
[error] | x$1 =>
[error] | x$1 match
[error] | {
[error] | case "hello" =>
[error] | println("hello back at you")
[error] | case _ =>
[error] | println("huh?")
[error] | }.
[error] four errors found
[error] four errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 5 s, completed Dec 17, 2021 10:31:28 AM
Do you think that is it possible to compile Akka with Scala 3 + ?
I read on their official documentation that it can be done
https://doc.akka.io/docs/akka/snapshot/project/scala3.html
Moreover, Akka Actor 2.6.17 supports Scala 3
https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor_3/2.6.17