[vala/0.52] genie: Accept accessibility and async modifiers on "construct" creation methods



commit df8003b88006d3eca6f4035b6c4f76864a400e39
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Nov 23 14:19:02 2021 +0100

    genie: Accept accessibility and async modifiers on "construct" creation methods
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/1235

 tests/Makefile.am             |  1 +
 tests/genie/class-abstract.gs | 12 ++++++++++++
 vala/valagenieparser.vala     | 16 ++++++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cf7198fa4..7fab0a41b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1220,6 +1220,7 @@ TESTS = \
        version/since-parameter.test \
        genie/case.gs \
        genie/class.gs \
+       genie/class-abstract.gs \
        genie/class-field.gs \
        genie/class-init.gs \
        genie/class-property.gs \
diff --git a/tests/genie/class-abstract.gs b/tests/genie/class-abstract.gs
new file mode 100644
index 000000000..b7f894b21
--- /dev/null
+++ b/tests/genie/class-abstract.gs
@@ -0,0 +1,12 @@
+init
+       print "abstract class"
+
+class abstract Test
+       a:string
+       construct protected()
+               a = "a"
+
+class abstract Test2
+       b:string
+       construct async protected()
+               b = "b"
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index d7f95cda9..f074df73d 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -3696,7 +3696,7 @@ public class Vala.Genie.Parser : CodeVisitor {
                CreationMethod method;
 
                expect (TokenType.CONSTRUCT);
-               parse_member_declaration_modifiers ();
+               var flags = parse_member_declaration_modifiers ();
 
                if (accept (TokenType.OPEN_PARENS)) {
                        /* create default name using class name */
@@ -3728,9 +3728,21 @@ public class Vala.Genie.Parser : CodeVisitor {
                                method.add_error_type (parse_type (true, false));
                        } while (accept (TokenType.COMMA));
                }
-               method.access = SymbolAccessibility.PUBLIC;
+
+               if (ModifierFlags.PRIVATE in flags) {
+                       method.access = SymbolAccessibility.PRIVATE;
+               } else if (ModifierFlags.PROTECTED in flags) {
+                       method.access = SymbolAccessibility.PROTECTED;
+               } else {
+                       method.access = SymbolAccessibility.PUBLIC;
+               }
+
                set_attributes (method, attrs);
 
+               if (ModifierFlags.ASYNC in flags) {
+                       method.coroutine = true;
+               }
+
                if (accept_block ()) {
                        method.body = parse_block ();
                        method.external = false;


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