[vala/0.52] genie: Properly handle plain "get" or "set" property accessors



commit d0e162f9a2dbc1dc913911d8ebc3ff0724832e35
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Nov 4 22:34:47 2021 +0100

    genie: Properly handle plain "get" or "set" property accessors
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/1248

 tests/Makefile.am             |  1 +
 tests/genie/class-property.gs | 16 ++++++++++++++++
 vala/valagenieparser.vala     |  4 ++++
 3 files changed, 21 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ed3156efe..34968c157 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1212,6 +1212,7 @@ TESTS = \
        version/since-method.test \
        version/since-parameter.test \
        genie/class.gs \
+       genie/class-property.gs \
        genie/control-flow-if-do.gs \
        genie/control-flow-if-else.gs \
        genie/control-flow-if-else-if.gs \
diff --git a/tests/genie/class-property.gs b/tests/genie/class-property.gs
new file mode 100644
index 000000000..d536a7bf5
--- /dev/null
+++ b/tests/genie/class-property.gs
@@ -0,0 +1,16 @@
+init
+       var a = new Test()
+       a.foo = "foo"
+       assert( a.foo == "foo" )
+       assert( a.bar == "bar" )
+       a.manam = "manam"
+       assert( a.manam == "manam" )
+
+class Test:Object
+       prop foo:string
+       prop readonly bar:string
+               get
+                       return "bar"
+       prop manam:string
+               owned get
+               set construct
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index a9ef56513..d7f95cda9 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -3142,6 +3142,8 @@ public class Vala.Genie.Parser : CodeVisitor {
                                        if (accept_block ()) {
                                                block = parse_block ();
                                                prop.external = false;
+                                       } else {
+                                               accept (TokenType.EOL);
                                        }
                                        prop.get_accessor = new PropertyAccessor (true, false, false, 
value_type, block, get_src (accessor_begin));
                                        set_attributes (prop.get_accessor, attribs);
@@ -3167,6 +3169,8 @@ public class Vala.Genie.Parser : CodeVisitor {
                                        if (accept_block ()) {
                                                block = parse_block ();
                                                prop.external = false;
+                                       } else {
+                                               accept (TokenType.EOL);
                                        }
                                        prop.set_accessor = new PropertyAccessor (false, !readonly, 
_construct, value_type, block, get_src (accessor_begin));
                                        set_attributes (prop.set_accessor, attribs);


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