[vala/1270-remove-static-codecontext-access] Symbol.add_destructor(): avoid use static code context



commit 74ee5d9e12dc571a4d7d0129779e40b634411db8
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Dec 29 23:12:53 2021 -0600

    Symbol.add_destructor(): avoid use static code context

 vala/valaclass.vala       | 8 ++++----
 vala/valagenieparser.vala | 2 +-
 vala/valaparser.vala      | 2 +-
 vala/valasymbol.vala      | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 7b164e344..b792f6c22 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -371,23 +371,23 @@ public class Vala.Class : ObjectTypeSymbol {
                }
        }
 
-       public override void add_destructor (Destructor d) {
+       public override void add_destructor (Destructor d, CodeContext context) {
                switch (d.binding) {
                case MemberBinding.INSTANCE:
                        if (destructor != null) {
-                               Report.error (d.source_reference, "class already contains a destructor");
+                               context.report.log_error (d.source_reference, "class already contains a 
destructor");
                        }
                        destructor = d;
                        break;
                case MemberBinding.CLASS:
                        if (class_destructor != null) {
-                               Report.error (d.source_reference, "class already contains a class 
destructor");
+                               context.report.log_error (d.source_reference, "class already contains a class 
destructor");
                        }
                        class_destructor = d;
                        break;
                case MemberBinding.STATIC:
                        if (static_destructor != null) {
-                               Report.error (d.source_reference, "class already contains a static 
destructor");
+                               context.report.log_error (d.source_reference, "class already contains a 
static destructor");
                        }
                        static_destructor = d;
                        break;
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 0db2479c5..d3346c53d 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -2756,7 +2756,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                } else if (sym is Constructor) {
                        cl.add_constructor ((Constructor) sym, context);
                } else if (sym is Destructor) {
-                       cl.add_destructor ((Destructor) sym);
+                       cl.add_destructor ((Destructor) sym, context);
                } else {
                        context.report.log_error (sym.source_reference, "unexpected declaration in class");
                }
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 349fafa06..286824b43 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -3464,7 +3464,7 @@ public class Vala.Parser : CodeVisitor {
                }
                d.body = parse_block ();
 
-               parent.add_destructor (d);
+               parent.add_destructor (d, context);
        }
 
        void parse_struct_declaration (Symbol parent, List<Attribute>? attrs) throws ParseError {
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 4f207867e..dab13b3b9 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -503,8 +503,8 @@ public abstract class Vala.Symbol : CodeNode {
                context.report.log_error (c.source_reference, "constructors are not allowed in `%s'", 
get_full_name ());
        }
 
-       public virtual void add_destructor (Destructor d) {
-               Report.error (d.source_reference, "destructors are not allowed in `%s'", get_full_name ());
+       public virtual void add_destructor (Destructor d, CodeContext context) {
+               context.report.log_error (d.source_reference, "destructors are not allowed in `%s'", 
get_full_name ());
        }
 
        public override string to_string () {


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