KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing a trait that should specify the method clone returning a CloneResult , as so: trait TraitWithClone extends Cloneable { def clone: CloneResult } The intention here is to tighten up the return type of java.lang.Object 's clone() to something useful to this interface. However, when I try to compile this, I get: error: overriding method clone in trait View2 of type ()CloneResult; method clone in class Object of type ()java.lang.Object has weaker access privileges; it should be public; (Note that method clone in trait View2 of type ()CloneResult is abstract, and is therefore overridden by concrete method clone in class Object of type ()java.lang.Object) How can I require that an implementation be public , when Scala doesn't have the keyword? I know I can do: trait TraitWithClone extends Cloneable { override def clone = cloneImpl protected def cloneImpl: CloneResult } ...but that seems like a hack. Any suggestions?
Tags (comma-separated)
Save Edits
Cancel