Scala: Problems with erasure on overriding equals function for parametrized classes

I'm having troubles on understanding well how to use manifests.

That's my problem: I've creat a new parametrized class C and tryed to override equals like this:

override def equals(that:Any)=that match{
 case that:C[T] => true /*do smth else not relevant*/
 case _ => false
}

Of course I recieve the "warning: non variable type-argument T in type pattern C[T] is unchecked since it is eliminated by erasure". I tryied so using manifests like I was using in many other functions:

override def equals(that:Any)(implicit manifest:Manifest[T])=that match{
 case that:C[T] => true
 case _ => false
}

But I recieved the "error: method equals overrides nothing" message.

I don't know how to fix this. Could anyone please help me?

Answers


You can't fix it. Welcome to the joys of smooth interoperation with java. The only way to improve equals from def equals(x: Any): Boolean is to write a different method.

I'm always trying to convince martin that we should implement == desugaring differently, aiming at something like "def decentEquals[T](x: T)(implicit equiv: Equiv[T])" with default implicits and bridge methods to make it seamless unless you care, but he thinks equality tests shouldn't get any slower.


Need Your Help

Apache 2 - LDAP/Active Directory - Automatic login/authentication process

windows apache authentication active-directory

Is there a fully automated way to authentication a user using IE8+ with Apache without the user having to enter any form of credentials?

String Comparison with Elasticsearch Groovy Dynamic Script

groovy elasticsearch

I have an elasticsearch index that contains various member documents. Each member document contains a membership object, along with various fields associated with / describing individual membership...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.