[vala/staging: 1/5] valaparser: Improve handling of unowned/owned keyword occurrences



commit ee7b9b97dc2e01b8d38299c844a62e7886baa33f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Nov 24 16:13:06 2017 +0100

    valaparser: Improve handling of unowned/owned keyword occurrences
    
    Don't throw an error on unexpected owned/unowned classification and
    output why it is superfuous in this context.

 vala/valaparser.vala |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 02677c6..59b4d5f 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -438,9 +438,18 @@ public class Vala.Parser : CodeVisitor {
                                                Report.warning (get_last_src (), "deprecated syntax, use 
`unowned` modifier");
                                        }
                                        value_owned = false;
+                               } else if (accept (TokenType.OWNED)) {
+                                       Report.warning (get_last_src (), "`owned' is default in this 
context");
                                }
                        } else {
-                               value_owned = accept (TokenType.OWNED);
+                               if (accept (TokenType.OWNED)) {
+                                       value_owned = true;
+                               } else {
+                                       value_owned = false;
+                                       if (accept (TokenType.UNOWNED)) {
+                                               Report.warning (get_last_src (), "`unowned' is default in 
this context");
+                                       }
+                               }
                        }
                }
 
@@ -2807,7 +2816,14 @@ public class Vala.Parser : CodeVisitor {
                                var accessor_access = parse_access_modifier (SymbolAccessibility.PUBLIC);
 
                                var value_type = type.copy ();
-                               value_type.value_owned = accept (TokenType.OWNED);
+                               if (accept (TokenType.OWNED)) {
+                                       value_type.value_owned = true;
+                               } else {
+                                       value_type.value_owned = false;
+                                       if (accept (TokenType.UNOWNED)) {
+                                               Report.warning (get_last_src (), "property getters are 
`unowned' by default");
+                                       }
+                               }
 
                                if (accept (TokenType.GET)) {
                                        if (prop.get_accessor != null) {


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