Interface methods not inherited as Abstract
Monkey Forums/Monkey Bug Reports/Interface methods not inherited as Abstract
| ||
I have a feeling this may have been posted a long time ago, but it's worth bringing up.#REFLECTION_FILTER="*" Import reflection Interface Foo Method Hello:Void() End Class Bar Implements Foo Abstract End Class Test Extends Bar Method Hello:Void() Print "Hello World" End End Function Main:Int() New Test().Hello() Return 0 End I would expect this to compile with no problems, but I get "Method Foo.Hello:Void() must be implemented by class Bar". To me, an abstract class should not be required to implement all methods in an interface. That contract should be passed down to the next concrete class (in this case, Test). Samah |
| ||
I posted this a while ago. In a nutshell its not a bug. This should solve it... Class Bar Implements Foo Abstract Method Hello:Void() Super.Hello() End Method End |
| ||
That's not quite the same problem, which is why I'm posting it here. You're saying that inherited methods are not used to complete the contract for an interface. I'm saying that you can't even compile abstract classes unless you implement all the methods of the interface there too. Cloning all the methods of the interface in the abstract class is an awful solution for me, as the interface has about 20-30 methods. So yes, it's either a bug, or "working as intended." I'd prefer that the latter NOT be the answer, because it just seems silly to me. |
| ||
Hmm...I agree, this looks like it should work - and a simple tweak to trans allows the code to translate. But c# doesn't like it (and c++ gives a VERY weird error): http://jelle.druyts.net/CommentView.aspx?guid=fe5e801e-71e5-474e-8235-01b2ad14ff68 I guess the compiler could potentially be tweaked to add abstract versions of all unimplemented interface methods to classes - but I wont be going there for a while yet. |
| ||
Aww... :( It works in Java! XD Edit: @marksibly: I guess the compiler could potentially be tweaked to add abstract versions of all unimplemented interface methods to classes - but I wont be going there for a while yet. I did something similar to this ages ago to allow for optional methods in interfaces. Essentially it just added an empty method with a default return value. |