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



commit 3090105892dac155d58ede6056d598aaa0376c23
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 86e5e378f..0109ec20d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1151,6 +1151,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 4173c4ae6..6a3f790a4 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -3121,6 +3121,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);
@@ -3146,6 +3148,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]