[vala/staging] vala: Let UsingDirective hold reference to UnresolvedSymbol instances only



commit 2f63d5f36b03e1619c9722ced1daea6edddf9fdf
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Oct 27 10:36:22 2018 +0200

    vala: Let UsingDirective hold reference to UnresolvedSymbol instances only
    
    This should break a cyclic reference of SourceReference and Namespace.

 vala/valausingdirective.vala | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/vala/valausingdirective.vala b/vala/valausingdirective.vala
index 15bb2d034..da5752cb0 100644
--- a/vala/valausingdirective.vala
+++ b/vala/valausingdirective.vala
@@ -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.


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