logo       

[jira] Updated: (BOO-314) Overeager member lookup in classes: msg#00086

lang.boo.devel

Subject: [jira] Updated: (BOO-314) Overeager member lookup in classes

[ http://jira.codehaus.org/browse/BOO-314?page=all ]

Doug Holton updated BOO-314:
----------------------------

Attachment: boo-314a.patch

This patch to ProcessMethodBodies appears to fix the problem. It doesn't
suffer from the problem I mentioned earlier, and all nant tests still work fine.

What it does is constrain name resolution to callable types first if a
reference expression is being invoked like a method.

It may not be the perfect solution, but it at least turns the problem on its
head. At worst I think you might have to add a "self." prefix now and then if
there is a name conflict.

Please test it out to see if it solves the problems you've had, or causes any.
Here are a couple of simple test cases:

//////////////////////////////////////////////////////////////////

import System.Windows.Forms from System.Windows.Forms
import System.Drawing from System.Drawing

class MyWin(Form):
def constructor():
Size = Size(300,400) //No longer need to qualify name here

Application.Run(MyWin())


//////////////////////////////////////////////////////

class fld:
pass

class C:
public fld as callable = {print("hello")}

def doit():
self.fld() //see now you'd have to qualify this with "self", but
only in this
//special case because there is also a type named
"fld",
//but I don't think it's a big deal. I
//think this is the rarer case anyway.

c_instance = C()
c_instance.doit()




> Overeager member lookup in classes
> ----------------------------------
>
> Key: BOO-314
> URL: http://jira.codehaus.org/browse/BOO-314
> Project: Boo
> Type: Bug
> Components: Compiler
> Versions: 0.5
> Reporter: steve donovan
> Attachments: boo-314a.patch
>
>
> The compiler can get confused if there is a member of a class which has the
> same name as some symbol from an included namespace. In the first case, it
> is pointing out that 'Form.Size' can't be called, and is not looking up
> further for the 'System.Drawing.Size' constructor. In the second case, it
> sees 'Form.DialogResult' and notes that this is a static method, rather than
> 'System.Windows.Forms.DialogResult'.
> import System.Windows.Forms from System.Windows.Forms
> import System.Drawing from System.Windows.Forms
> class MyForm(Form):
> def constructor():
> // BCE0077: It is not possible to invoke an expression of type
> 'System.Drawing.Size'.
> Size = Size(200,200)
>
> static def go():
> f = MyForm()
> // BCE0058: Object required.
> if f.ShowDialog() == DialogResult.OK:
> print 'ok'
> The workaround is to fully qualify these names, but this is ugly and
> inconsistent. We know C# understands this issue properly, so a solution must
> be possible.

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise