[Mono-list] Using-alias patch
Joshua Tauberer
tauberer@for.net
Fri, 10 Jan 2003 12:22:26 -0500
This is a multi-part message in MIME format.
--------------080405070306060504040502
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
The attached patch should fix two problems with using-alias. (I don't
have CVS access...)
The one that caught my attention was:
using A = Some.Other.Class;
...
A[] x;
which fails to resolve A[]
And http://bugzilla.ximian.com/show_bug.cgi?id=35567
using A = Some.Namespace;
...
A.SomeClass[] x;
which has the same problem but for a different reason
The patch affects mcs/mcs/namespace.cs
Ooo, my first ever patch to an open source project.
Thanks to whoever commits it, if it's okay.
--
- Joshua Tauberer
http://taubz.for.net
** Nothing Unreal Exists **
--------------080405070306060504040502
Content-Type: text/plain;
name="arrayspatch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="arrayspatch"
Index: namespace.cs
===================================================================
RCS file: /mono/mcs/mcs/namespace.cs,v
retrieving revision 1.15
diff -u -p -r1.15 namespace.cs
--- namespace.cs 13 Dec 2002 09:46:54 -0000 1.15
+++ namespace.cs 10 Jan 2003 16:15:34 -0000
@@ -133,12 +133,33 @@ namespace Mono.CSharp {
{
string value = null;
+ string aliaspostpend = "";
+ string lookupname = alias;
+
+ // Do an alias check on only the part of the name before the first dot,
+ // if there is a dot and the dot isn't at the start of the name.
+ int x = lookupname.IndexOf(".");
+ if (x > 0) {
+ aliaspostpend = lookupname.Substring(x);
+ lookupname = lookupname.Substring(0, x);
+ } else {
+ // Strip off trailing []s for alias lookup
+ while (lookupname.EndsWith("[]")) {
+ aliaspostpend += "[]";
+ lookupname = lookupname.Substring(0, lookupname.Length-2);
+ }
+ }
+
// System.Console.WriteLine ("Lookup " + alias + " in " + name);
if (aliases != null)
- value = (string) (aliases [alias]);
+ value = (string) (aliases [lookupname]);
if (value == null && Parent != null)
- value = Parent.LookupAlias (alias);
+ value = Parent.LookupAlias (lookupname);
+
+ // Add back whatever we chopped off
+ if (value != null)
+ value += aliaspostpend;
return value;
}
--------------080405070306060504040502--