After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 646713 - PATCH: Implement alias functionality for 'using' directive
PATCH: Implement alias functionality for 'using' directive
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Parser
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-04-04 14:09 UTC by Jim Peters
Modified: 2018-05-22 13:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
PATCH: Implement alias functionality for 'using' directive (11.82 KB, patch)
2011-04-04 14:09 UTC, Jim Peters
none Details | Review

Description Jim Peters 2011-04-04 14:09:53 UTC
Created attachment 185109 [details] [review]
PATCH: Implement alias functionality for 'using' directive

Vala currently (0.12.0) has no way 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
Comment 1 Evan Nemerson 2013-12-10 20:12:32 UTC
Even without "using Queue = Gee.Queue", you can still just use "Gee.Queue" in your code, just like you can without any using statement at all.
Comment 2 GNOME Infrastructure Team 2018-05-22 13:59:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/189.