Implementing interface methods

Monkey Forums/Monkey Programming/Implementing interface methods

Shagwana(Posted 2013) [#1]
I understand that a class should implement all the methods of a interface. However I have seen that if that class is extending a class with the method in then the interface is not complete.

Consider the following code...

Strict

Interface inter_i

	Method draw:Void(n:Int)

End Interface

Class lvl1_c 

	Method draw:Void(n:Int)
		Print "levl1_c printing - "+n
	End Method
		
End Class


Class lvl2_c Extends lvl1_c	Implements inter_i

	'draw is implemented in lvl1_c


'	Method draw:Void(n:Int)'
'		Print "levl2_c printing - "+n
'	End Method


End Class


Function Main:Int()

	Local a:inter_i = New lvl2_c
	a.draw(34)
	
	Return 0
End Function


Now this looks like it *should* work, but does not.

Trying to compile the above results in a lvl2_c must implement the draw method error. Is this right?


ziggy(Posted 2013) [#2]
It seems the compiler does not take into account inherited methods when it tries to determine if all interface methods are implemented.
I *think* this should be considered a bug, but anyway, in the other hand, it's weird. If you mark the parent class as implementing the interface, extending classes do inherit also this.


Shagwana(Posted 2013) [#3]
Yeah, I think its a bug as well so I will log it up in the bug report section. Logged here.