[vala/staging] vala: Fully qualify member-access when using-directive was used to resolve



commit 866258f688d781f3536892b8f93abdd3112198ec
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jul 15 17:46:58 2020 +0200

    vala: Fully qualify member-access when using-directive was used to resolve
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/57

 tests/girwriter/GirTest-1.0.gir-expected | 10 ++++++++++
 tests/girwriter/girtest.vala             |  3 +++
 tests/girwriter/girtest.vapi-expected    |  1 +
 vala/valamemberaccess.vala               | 11 +++++++++++
 4 files changed, 25 insertions(+)
---
diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected
index d244862d0..e0d5128a1 100644
--- a/tests/girwriter/GirTest-1.0.gir-expected
+++ b/tests/girwriter/GirTest-1.0.gir-expected
@@ -656,6 +656,16 @@
                                <type name="none"/>
                        </return-value>
                </virtual-method>
+               <method name="method_with_default" c:identifier="gir_test_object_test_method_with_default">
+                       <return-value transfer-ownership="full">
+                               <type name="none"/>
+                       </return-value>
+                       <parameters>
+                               <parameter name="i" transfer-ownership="none">
+                                       <type name="gint" c:type="gint"/>
+                               </parameter>
+                       </parameters>
+               </method>
                <method name="skipped_method" c:identifier="gir_test_object_test_skipped_method" 
introspectable="0">
                        <return-value transfer-ownership="full">
                                <type name="none"/>
diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala
index 23daab3d9..a63b6d4c3 100644
--- a/tests/girwriter/girtest.vala
+++ b/tests/girwriter/girtest.vala
@@ -257,6 +257,9 @@ namespace GirTest {
                public virtual void method_throw () throws ErrorTest {
                }
 
+               public void method_with_default (int i = Priority.HIGH) {
+               }
+
                public virtual signal void signal_with_default_handlder (int i1) {
                }
 
diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected
index 16d5de559..b09de120d 100644
--- a/tests/girwriter/girtest.vapi-expected
+++ b/tests/girwriter/girtest.vapi-expected
@@ -68,6 +68,7 @@ namespace GirTest {
                public virtual void method_throw () throws GirTest.ErrorTest;
                public void method_valist (int param, va_list vargs);
                public void method_varargs (int param, ...);
+               public void method_with_default (int i = GLib.Priority.HIGH);
                public virtual void method_with_default_impl (int8 param);
                public ObjectTest.new_valist (int param, va_list vargs);
                public ObjectTest.newv (int param, ...);
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index db022fefd..02d3b50ad 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -337,6 +337,17 @@ public class Vala.MemberAccess : Expression {
                                                        Report.error (source_reference, "`%s' is an ambiguous 
reference between `%s' and `%s'".printf (member_name, symbol_reference.get_full_name (), 
local_sym.get_full_name ()));
                                                        return false;
                                                }
+
+                                               // Transform to fully qualified member access
+                                               unowned Symbol? inner_sym = local_sym.parent_symbol;
+                                               unowned MemberAccess? inner_ma = this;
+                                               while (inner_sym != null && inner_sym.name != null) {
+                                                       inner_ma.inner = new MemberAccess (null, 
inner_sym.name, source_reference);
+                                                       inner_ma = (MemberAccess) inner_ma.inner;
+                                                       inner_sym = inner_sym.parent_symbol;
+                                               }
+                                               inner.check (context);
+
                                                symbol_reference = local_sym;
                                        }
                                }


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