Re: [Vala] [PATCH] Implement alias functionality for 'using' directive



Jim Peters wrote:
Required to disambiguate symbol references in case of matches from
multiple 'using' statements.

I've implemented the alias functionality missing from 'using'.  It
took 3 tries before I found a way that worked and didn't upset the
existing code too much.

As Vala tries to follow C#, I've done it the C# way.  According to the
C# language spec 9.3.2, an alias can be used to disambiguate the case
which at the moment gives an "ambiguous reference" error.

I've added error messages that suggest the using directives that the
user can insert to resolve the issue.

For example, compiling the following code with this patch:

  using Gee;

  public void main() {
     Queue queue = new LinkedList<Object>();
  }

gives the following error message:

  bug.vala:4.2-4.6: error: `Queue' is an ambiguous reference; add one of these aliases to resolve:
        using Queue = GLib.Queue;
        using Queue = Gee.Queue;
     Queue queue = new LinkedList<Object>();
     ^^^^^

Adding in 'using Queue = Gee.Queue;' fixes the problem.  This code
builds now:

  using Gee;
  using Queue = Gee.Queue;

  public void main() {
     Queue queue = new LinkedList<Object>();
  }

I've tried to follow the existing style.  I checked all the code
related to existing 'using' functionality -- I hope I got it right.
I've added a new test case, and the existing test cases pass.

If this patch isn't okay, I can make changes and reissue.

Jim

-- 
 Jim Peters                  (_)/=\~/_(_)                 jim uazu net
                          (_)  /=\  ~/_  (_)
 Uazú                  (_)    /=\    ~/_    (_)                http://
 in Peru            (_) ____ /=\ ____ ~/_ ____ (_)            uazu.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]