KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why is it possible to override an empty-parentheses method with an object ? trait A { def meth = {} def meth_p() = {} } class B extends A { object meth_p } // compiles Overriding the method without parentheses does not compile: class B1 extends A { object meth } // does not compile Neither do any of the following combinations work (without override modifier): class BX extends A { // of course, each declaration should get its own class def meth = {} def meth_p() = {} def meth() = {} def meth_p = {} val meth = {} val meth_p = {} // ... } Is this documented and useful behaviour? I’ve just run into a very subtle bug because of this accidental override.
Tags (comma-separated)
Save Edits
Cancel