I recently ran into a problem when developing with Spring Security. It has a GrantedAuthority interface with the following signature:
public interface GrantedAuthority extends Serializable, Comparable
And as for Java 1.5 and later, the Comparable interface accepts a parameter of type T , which is omitted in Spring's security libraries (obviously, for compatibility with JVM 1.4).
So, I'm trying to implement GrantedAuthority in Scala.
class Role extends GrantedAuthority { . . . def compareTo(obj: Any): Int = obj match { case (r: Role) => r.toString.compareTo(this.toString) case _ => -1 } }
It does not compile:
error: class Role needs to be abstract, since method compareTo in trait Comparable of type (T)Int is not defined
How can I implement such an interface in Scala?
inheritance scala language-interoperability
incarnate
source share