]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Write delegates as qualified types in code writer
authorRyan Lortie <desrt@desrt.ca>
Tue, 15 Mar 2011 21:09:54 +0000 (22:09 +0100)
committerJürg Billeter <j@bitron.ch>
Tue, 15 Mar 2011 21:09:54 +0000 (22:09 +0100)
Fixes bug 643927.

vala/valadatatype.vala
vala/valadelegatetype.vala

index d13e5e09cf4f9897488cefb3a28ed89c0f5a6ef2..9521aee71cc9907d6050c02a693c7f8bad748797 100644 (file)
@@ -171,6 +171,8 @@ public abstract class Vala.DataType : CodeNode {
        }
 
        public virtual string to_qualified_string (Scope? scope = null) {
+               // logic temporarily duplicated in DelegateType class
+
                string s;
 
                if (data_type != null) {
index c5f2ec8e0281b0b2d69e81b5a37ec7cfcf7a636f..da17014ee713a7d581ef1ca21503c3d1bb2764e5 100644 (file)
@@ -47,7 +47,27 @@ public class Vala.DelegateType : DataType {
        }
 
        public override string to_qualified_string (Scope? scope) {
-               string s = delegate_symbol.get_full_name ();
+               // logic temporarily duplicated from DataType class
+
+               Symbol global_symbol = delegate_symbol;
+               while (global_symbol.parent_symbol.name != null) {
+                       global_symbol = global_symbol.parent_symbol;
+               }
+
+               Symbol sym = null;
+               Scope parent_scope = scope;
+               while (sym == null && parent_scope != null) {
+                       sym = parent_scope.lookup (global_symbol.name);
+                       parent_scope = parent_scope.parent_scope;
+               }
+
+               string s;
+
+               if (sym != null && global_symbol != sym) {
+                       s = "global::" + delegate_symbol.get_full_name ();;
+               } else {
+                       s = delegate_symbol.get_full_name ();
+               }
 
                var type_args = get_type_arguments ();
                if (type_args.size > 0) {