When passing functions as references, Boo does not know which reference to pass when you have overriden the virtual method in a derived class.
In cases like these, Boo should pass derived function references when the self keyword is used, and the base class reference when thesuper keyword is used.
Take the following code snippet that someone posted to boolang as an example / test case / whatever.
class StatemachineBase:
state = self._S_OFF_
virtual def _S_OFF_():
pass
virtual def _S_AUTO_():
pass
- etc.
class StatemachineDerived(StatemachineBase):
override def _S_OFF_():
super._S_OFF_()
if true:
self.state = self._S_AUTO_ # BCE0004: Ambiguous reference '_S_AUTO_': StatemachineDerived._S_AUTO_(), StatemachineBase._S_AUTO_().
override def _S_AUTO_():
super._S_AUTO_()
if true:
self.state = self._S_OFF_ # BCE0004: Ambiguous reference '_S_OFF_': StatemachineDerived._S_OFF_(), StatemachineBase._S_OFF_().
print 'compiled and ran?'
Also, the way I fixed it, I also changed the behavior of BOO-250. If you have a callable reference to an overloaded function, instead of choking, boo will simply pick the first one for now. So code like below works now:
def overloaded(x as int):
print "1st overload"
def overloaded(x as int, y as int):
print "2nd overload"
p = double.Parse //Parse is overloaded, so didn't work before
d = p("3.14")
print d, d.GetType()
ov = overloaded //another overload test
ov(1)