About Overloaded Method error

15 views
Skip to first unread message

Bereket Workie Anteneh

unread,
Aug 2, 2021, 10:56:31 AMAug 2
to scalismo
Dear Scalismo community,
I want to do landmark error analysis for my SSM. 
But on my code it says, "cannot resolve overloaded method" 'writeAll'.  
When I use  package
import scala.collection.JavaConversions._   This error is okay except the package 'JavaConversions' is outdate with my Scala version.
However, when I use package  
import scala.collection.JavaConverters._ it says, "cannot resolve overloaded method" 'writeAll'.
Since my Scala version is 2.12.6 I have to use the package 
import scala.collection.JavaConverters._
So, how I can fix the error "cannot resolve overloaded method" 'writeAll'? or
Is there any method that can substitute the method 'writeAll'?

With regards,

Marcel Luethi

unread,
Aug 3, 2021, 2:41:30 AMAug 3
to Bereket Workie Anteneh, scalismo
Hi Bereket

There is no method called writeAll in Scalismo. I suspect that it is one of your methods that fails? The error indicates that you don't provide the correct type to the function call. As the compiler can choose between several overloaded methods, it cannot tell you which type it expects. It might help to explicitly annotate the type that you expect as follows:

val collectionToPass : TYPE_YOU_NEED = yourCollection
writeAll(collectionToPass)

In this way you should get a clear compiler message.

Best regards,
Marcel


--
You received this message because you are subscribed to the Google Groups "scalismo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalismo+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/d7560fc9-ac8a-44ae-9c65-c308a1ead1dcn%40googlegroups.com.

Bereket Workie Anteneh

unread,
Aug 4, 2021, 10:05:50 AMAug 4
to Marcel Luethi, scalismo
Thank you Marcel, 
Based on your  recommendation I tried to fix the error but still now the following error is shown .
Error:(39, 37) type mismatch;
 found   : List[Array[String]] (in scala.collection.immutable)
 required: List[Array[String]] (in java.util)
    writer2.writeAll(listOfRecords2.toList)
Error:(160, 35) type mismatch;
 found   : List[Array[String]] (in scala.collection.immutable)
 required: List[Array[String]] (in java.util)
    writer.writeAll(listOfRecords.toList)
How I can fix those errors?

With regards,
Error.PNG

Marcel Luethi

unread,
Aug 5, 2021, 4:13:46 AMAug 5
to Bereket Workie Anteneh, scalismo
Hi Bereket

The error message says that you are using java's List instead of the List class provided by Scala.
Is there a specific reason that you need to use Java collections? I would try not to mix them too much. Ideally, if you really have to use Java collect, you convert them once very early in your program and work with the Scala collections from there.

Best regards
Marcel

Marcel Luethi

unread,
Aug 7, 2021, 5:39:17 AMAug 7
to Bereket Workie Anteneh, scalismo
Hi Bereket

Your problem is still the same. You need to convert a java collection to a scala collection. This can, for example be done as follows:

import scala.jdk.CollectionConverters._
val ljava : java.util.List[Landmark[_3D]] = ???
val l : List[Landmark[_3D]] = ljava.asScala.toList
I would, however, like to reiterate that this is not a Scalismo problem, and you should address such questions in the future to the appropriate forum (or simple search on stackoverflow).

Best regards,

Marcel

Reply all
Reply to author
Forward
0 new messages