Tried compiling this example https://github.com/akka/akka/blob/master/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala#L1, using Eclipse.
Came back with
an error on the last few lines...
namely
} yield system.actorOf(Props(classOf[FSMHakker], name, chopsticks(i), chopsticks((i + 1) % 5)))
gives type mismatch; found : ClassFSMHakker required: () => 0
and hakkers.foreach(_ ! Think)
gives value ! is not a member of Nothing.
Any tips to get this to compile without errors appreciated.
You are referring to a sample from the snapshot docs, but your error message suggests that you are using a released (older) version of Akka.
Related
I'm using Scala Worksheet in IntelliJ IDEA and sometimes I get this kind of error. For example this is my code:
def silnia(n:Int):Int=
if n==0 then 1
else if n>0 then n*silnia(n-1)
else throw new Exception(s"negative number: $n")
It compiled normally before both in IntelliJ and Terminal and I got the expected result:
def silnia(n: Int): Int
but now it doesn't and instead I get this error '(' expected but identifier found. I don't think the problem is in the code but I could be wrong. Does anyone know how to solve this problem?
I recently revived an old library that was written in scala 2.9, and I created a new scala project using scala 2.13.2
I am getting errors like the following:
type mismatch;
found : scala.collection.mutable.Buffer[Any]
[error] required: Seq[Any]
Was there a specific change between 2.9 to 2.13.2 that involved not implicitly casting sequences or something that might solve many of these types of compile errors?
I had to add .toSeq to many of my function return statements that were vals of Buffer[Any] that needed to be passed as an arguement to a function expected a Sequence.
Quite a lot things happened in the last 7+ years (including rewrite of the collections library).
If adding .toSeq solves your problem - just go for it.
If you want to know what exactly has changed - try upgrading version-by version: first upgrade to scala-2.10., then to 2.11., then 2.12.*, then, finally, to 2.13.2.
At each upgrade you'll probably see deprecation warnings. Fix them before upgrading to the next version.
Brave, but perhaps bad form, to disturb the dead. Nevertheless, maybe pass mutable.Buffer as mutable.Seq instead of Seq which is by default immutable.Seq. Consider
val mb = mutable.Buffer(11, Some(42))
val ms: mutable.Seq[Any] = mb // OK
val is: Seq[Any] = mb // NOK
In Scala, we can get a compile error with a message containing 'NotInferedT'. For example :
expected: (NotInferedT, NotInferedT) => Boolean, actual: (Nothing, Nothing)
(as seen here ).
This messge is coming from the Scala compiler, and it appears to mean that Scala cannot infer a type. But is 'NotInferedT' itself a type ? And is it described in the Scala documentation somewhere ?
I can't find 'NotInferedT' in the Scala API docs .
It's the way the Scala plugin (which is basically a Scala compiler) for IntelliJ IDEA names an undefined type it can't resolve:
case UndefinedType(tpt, _) => "NotInfered" + tpt.name
I will not paste the code here, I simply have this:
https://github.com/akka/akka/blob/master/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Main.scala
And I wonder why Eclipse gives error on
def receive
saying:
type mismatch; found : Any => Unit required: akka.actor.Actor.Receive
(which expands to) PartialFunction[Any,Unit]
I suppose it's something about the fact that there are some "case" statements inside a block without a "match" in front.
How can I remove the error, or how can I make eclipse runnning well with Akka?
I'm trying to assign groups to TestNG classes and methods in a Scala environment (in Eclipse)
#Test(groups="register")
class RegisterTest {
...
but am encountering the following error:
Multiple markers at this line
- type mismatch; found : java.lang.String("register") required:
Array[java.lang.String]
- annotation argument needs to be a constant; found: "register"{<error>}
I've tried applying groups to individual Scala methods but still encounter the same error.
Any suggestions on how to get around this?
The#Testannotation works as long as it doesn't specify any parameters (same error if dependsOnMethodsparameter is specified).
#DataProviderannotation also works.
The ScalaDoc gives the following example:
#Test(groups = Array("com.mycompany.groups.SlowTest"))
def funTest() {
sb.append("fun!")
assert(sb.toString === "ScalaTest is fun!")
assert(lb.isEmpty)
}
That seems to match the error you get.