From: Ryan Lortie Date: Tue, 15 Mar 2011 21:09:54 +0000 (+0100) Subject: Write delegates as qualified types in code writer X-Git-Tag: 0.11.7~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=31bd6527da6189d72b8b7bc8cbe287c78ba70bfd;p=thirdparty%2Fvala.git Write delegates as qualified types in code writer Fixes bug 643927. --- diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala index d13e5e09c..9521aee71 100644 --- a/vala/valadatatype.vala +++ b/vala/valadatatype.vala @@ -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) { diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala index c5f2ec8e0..da17014ee 100644 --- a/vala/valadelegatetype.vala +++ b/vala/valadelegatetype.vala @@ -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) {