History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-656
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Doug H
Reporter: Arron Washington
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Boo is stupid when dealing with virtual methods passed by reference

Created: 10/Feb/06 01:23 PM   Updated: 18/Feb/06 10:25 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 0.7.6

Time Tracking:
Not Specified

File Attachments: 1. Text File boo656c.patch (5 kb)

Issue Links:
Related
 


 Description  « Hide
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

  1. 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?'



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Doug H - 10/Feb/06 06:45 PM
This patch fixes a lot of cases, but "nant test" shows a cdata error, which may mean a peverify error somewhere. I will try to work that out later, but thought I'd go ahead and post it here anyway.

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)


Doug H - 10/Feb/06 07:26 PM
The peverify issue was because I was setting a superclass field from the constructor of a subclass before the subclass called super(). I.E.:

class derived...:
def constructor():
self.state = _S_AUTO_ //bad, don't do this til after super() is called
super()

So I just changed the test case. Everything works now. We can make another jira issue for the above issue if need be, but it is pretty obscure.