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



commit e4029a911ecf0e86da9d7b23f37b4aeb110018ae
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Dec 29 23:03:07 2021 -0600

    Symbol.add_constructor(): avoid use static code context

 vala/valaclass.vala       | 10 +++++-----
 vala/valagenieparser.vala |  2 +-
 vala/valaparser.vala      |  2 +-
 vala/valasymbol.vala      |  4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 80abbb093..7b164e344 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -338,23 +338,23 @@ public class Vala.Class : ObjectTypeSymbol {
                }
        }
 
-       public override void add_constructor (Constructor c) {
+       public override void add_constructor (Constructor c, CodeContext context) {
                switch (c.binding) {
                case MemberBinding.INSTANCE:
                        if (constructor != null) {
-                               Report.error (c.source_reference, "class already contains a constructor");
+                               context.report.log_error (c.source_reference, "class already contains a 
constructor");
                        }
                        constructor = c;
                        break;
                case MemberBinding.CLASS:
                        if (class_constructor != null) {
-                               Report.error (c.source_reference, "class already contains a class 
constructor");
+                               context.report.log_error (c.source_reference, "class already contains a class 
constructor");
                        }
                        class_constructor = c;
                        break;
                case MemberBinding.STATIC:
                        if (static_constructor != null) {
-                               Report.error (c.source_reference, "class already contains a static 
constructor");
+                               context.report.log_error (c.source_reference, "class already contains a 
static constructor");
                        }
                        static_constructor = c;
                        break;
@@ -589,7 +589,7 @@ public class Vala.Class : ObjectTypeSymbol {
                if (is_singleton && constructor == null) {
                        var c = new Constructor (source_reference);
                        c.body = new Block (source_reference);
-                       add_constructor (c);
+                       add_constructor (c, context);
                }
 
                if (base_class != null && base_class.is_sealed) {
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 797aae55e..0db2479c5 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -2754,7 +2754,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                } else if (sym is Property) {
                        cl.add_property ((Property) sym, context);
                } else if (sym is Constructor) {
-                       cl.add_constructor ((Constructor) sym);
+                       cl.add_constructor ((Constructor) sym, context);
                } else if (sym is Destructor) {
                        cl.add_destructor ((Destructor) sym);
                } else {
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index d3d65d786..349fafa06 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -3438,7 +3438,7 @@ public class Vala.Parser : CodeVisitor {
                }
                c.body = parse_block ();
 
-               parent.add_constructor (c);
+               parent.add_constructor (c, context);
        }
 
        void parse_destructor_declaration (Symbol parent, List<Attribute>? attrs) throws ParseError {
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 775e8c6cb..4f207867e 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -499,8 +499,8 @@ public abstract class Vala.Symbol : CodeNode {
                context.report.log_error (sig.source_reference, "signals are not allowed in `%s'", 
get_full_name ());
        }
 
-       public virtual void add_constructor (Constructor c) {
-               Report.error (c.source_reference, "constructors are not allowed in `%s'", get_full_name ());
+       public virtual void add_constructor (Constructor c, CodeContext context) {
+               context.report.log_error (c.source_reference, "constructors are not allowed in `%s'", 
get_full_name ());
        }
 
        public virtual void add_destructor (Destructor d) {


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