[svn] r6499: nemerle/trunk/ncc: hierarchy/GlobalEnv.n
testsuite/positive/names-lookup.n
nazgul
svnadmin at nemerle.org
Wed Aug 9 23:01:14 CEST 2006
Log:
Expand aliases in first element of opened namespace
Author: nazgul
Date: Wed Aug 9 23:01:08 2006
New Revision: 6499
Modified:
nemerle/trunk/ncc/hierarchy/GlobalEnv.n
nemerle/trunk/ncc/testsuite/positive/names-lookup.n
Modified: nemerle/trunk/ncc/hierarchy/GlobalEnv.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/GlobalEnv.n (original)
+++ nemerle/trunk/ncc/hierarchy/GlobalEnv.n Wed Aug 9 23:01:08 2006
@@ -328,12 +328,22 @@
public AddOpenNamespace (ns : list [string], loc : Location) : GlobalEnv
{
- AddOpenNamespace (nameTree.ExactPath (ns), loc)
+ match (ns) {
+ | head :: tail =>
+ mutable possible_expansions = [nameTree.ExactPath (ns)];
+ foreach ((short, long) when short == head in namespace_aliases)
+ possible_expansions ::= nameTree.ExactPath (NString.Split (long, '.')).Path (tail);
+
+ AddOpenNamespace (possible_expansions, loc)
+
+ | _ => Util.ice ("empty or null namespace cannot be opened")
+ }
}
- private AddOpenNamespace (ns : NamespaceTree.Node, loc : Location) : GlobalEnv
+ private AddOpenNamespace (nses : list [NamespaceTree.Node], loc : Location) : GlobalEnv
{
- mutable all_opened = [ns];
+ mutable all_opened = nses;
+ foreach (ns in nses) {
// in case we are inside some namespace, we must open every namespace path
// composed of current namespace's parts suffixed with opened one
def open_nested (curr : NamespaceTree.Node) {
@@ -343,6 +353,7 @@
}
}
open_nested (current_namespace);
+ }
// we will warn when none of created namespace parts exists as real namespaces
nameTree.referenced_namespace_nodes.Add ((all_opened, loc));
Modified: nemerle/trunk/ncc/testsuite/positive/names-lookup.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/names-lookup.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/names-lookup.n Wed Aug 9 23:01:08 2006
@@ -83,6 +83,7 @@
_ = a.x();
_ = a.Y;
Composed3.Class2.Run ();
+ AliasesExpansion.X.M.Run ();
}
public Y : Y {
@@ -203,7 +204,26 @@
}
}
+namespace AliasesExpansion {
+ using System;
+ using SC = System.Collections;
+ using SC = System.Console;
+
+ namespace X
+ {
+ using SC.Generic; // ERROR!
+ module M
+ {
+ public Run() : void
+ {
+ def x = List ();
+ x.Add (1);
+ SC.WriteLine(x[0]);
+ }
+ }
+ }
+}
/*
@@ -214,5 +234,6 @@
in NullEnumerable
constructing Y()
NS1.NS2.Class1.Hello
+1
END-OUTPUT
*/
More information about the svn
mailing list