From 2f63d5f36b03e1619c9722ced1daea6edddf9fdf Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sat, 27 Oct 2018 10:36:22 +0200 Subject: [PATCH] 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. -- 2.47.2