]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Recursively check for Version.deprecated attribute from bottom to top
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 24 Apr 2023 08:00:44 +0000 (10:00 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 5 Apr 2024 14:00:49 +0000 (16:00 +0200)
vala/valamemberaccess.vala
vala/valaversionattribute.vala

index 08b5b384e90f6354907dbc5f215ab15239b56a69..4360b4e60b7e5af389237c5754333a67fcca021d 100644 (file)
@@ -921,7 +921,9 @@ public class Vala.MemberAccess : Expression {
                if (parent != member) {
                        member.used = true;
                }
-               member.version.check (context, source_reference);
+               if (!(parent_node is MemberAccess)) {
+                       member.version.check (context, source_reference);
+               }
 
                // FIXME Code duplication with MemberInitializer.check()
                if (access == SymbolAccessibility.PROTECTED && member.parent_symbol is TypeSymbol) {
index aca09768e3ba4066eff20ac438273a906950e2c9..c7a63373be672eaa97927a8454c0b3bc9e480737 100644 (file)
@@ -50,12 +50,21 @@ public class Vala.VersionAttribute {
         */
        public bool deprecated {
                get {
-                       if (_deprecated == null) {
+                       if (_deprecated != null) {
+                               return _deprecated;
+                       }
+                       if (symbol.has_attribute ("Version")
+                           // [Deprecated] is deprecated
+                           || symbol.has_attribute ("Deprecated")) {
                                _deprecated = symbol.get_attribute_bool ("Version", "deprecated", false)
                                        || symbol.has_attribute_argument ("Version", "deprecated_since")
                                        || symbol.has_attribute_argument ("Version", "replacement")
                                        // [Deprecated] is deprecated
                                        || symbol.has_attribute ("Deprecated");
+                       } else if (symbol.parent_symbol != null) {
+                               _deprecated = symbol.parent_symbol.version.deprecated;
+                       } else {
+                               _deprecated = false;
                        }
                        return _deprecated;
                }