Weird issue with inheritance and interfaces

Monkey Forums/Monkey Bug Reports/Weird issue with inheritance and interfaces

ziggy(Posted 2012) [#1]
This code replicates the issue:
Function Main()
	Local a:= New MyExtendedClass
	SimpleFunction(a)
end


Interface MyBaseInterface
	Method DoSomething:String(value1:Int)
End

Interface MyExtendedInterface Extends MyBaseInterface
	Method DoSomethingMore:String(value2:Int)
End

Class MyBaseClass implements MyBaseInterface
	Method DoSomething:String(value1:Int)
		Print "Something being done"
		Return "Hello!"
	end
End

Class MyExtendedClass extends MyBaseClass implements MyExtendedInterface 
	Method DoSomethingMore:String(value2:Int)
		Return "The number is " + value2
	end
End

Function SimpleFunction(a:MyExtendedInterface)
	a.DoSomething(12)
End

The compiler is providing this error:
C:/Users/Manel/etc.monkey<23> : Error : Method MyBaseInterface.DoSomething:String(Local value1:Int) must be implemented by class MyExtendedClass

This is weird as this method is already implemented on MyExtendedClass, it's being inherited from its "super" wich is already implemeting the "super" interface.


marksibly(Posted 2012) [#2]
Hi,

Can't remember which, but one (or more) target language(s) (as3?) don't allow you to use an inherited method to implement an interface method, so Monkey doesn't.

I guess Monkey could automatically add a 'forwarding' super call method, but not now...