[vala/staging] vala: Don't mark method as used on recursive usage of itself



commit 47e0679af3cbaafea39324d15b37de63144c03a8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Nov 5 11:14:26 2019 +0100

    vala: Don't mark method as used on recursive usage of itself
    
    See https://gitlab.gnome.org/GNOME/vala/issues/100

 vala/valamemberaccess.vala | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 421ee8a9f..e09c36551 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -737,7 +737,17 @@ public class Vala.MemberAccess : Expression {
                        member = symbol_reference;
                }
 
-               member.used = true;
+               // recursive usage of itself doesn't count as used
+               unowned CodeNode? parent = this;
+               while (parent != member) {
+                       parent = parent.parent_node;
+                       if (parent == null || parent == member) {
+                               break;
+                       }
+               }
+               if (parent != member) {
+                       member.used = true;
+               }
                member.version.check (source_reference);
 
                if (access == SymbolAccessibility.PROTECTED && member.parent_symbol is TypeSymbol) {


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