]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Let UsingDirective hold reference to UnresolvedSymbol instances only
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 27 Oct 2018 08:36:22 +0000 (10:36 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 27 Oct 2018 11:10:18 +0000 (13:10 +0200)
This should break a cyclic reference of SourceReference and Namespace.

vala/valausingdirective.vala

index 15bb2d034950ee2475324d6442c573c1822eb5d4..da5752cb01654333170f1010ed276f751eac8782 100644 (file)
@@ -29,7 +29,26 @@ public class Vala.UsingDirective : CodeNode {
        /**
         * The symbol of the namespace this using directive is referring to.
         */
-       public Symbol namespace_symbol { get; set; }
+       public weak Symbol namespace_symbol {
+               get {
+                       if (unresolved_symbol != null) {
+                               return unresolved_symbol;
+                       }
+                       return _namespace_symbol;
+               }
+               set {
+                       if (value is UnresolvedSymbol) {
+                               unresolved_symbol = (UnresolvedSymbol) value;
+                               _namespace_symbol = null;
+                       } else {
+                               _namespace_symbol = value;
+                               unresolved_symbol = null;
+                       }
+               }
+       }
+
+       weak Symbol _namespace_symbol;
+       UnresolvedSymbol unresolved_symbol;
 
        /**
         * Creates a new using directive.