[vala] parser: Report error only for private instance fields in structs



commit e0adb081fc11e563b037e19b2b85bcdc93a437c3
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Aug 14 14:28:21 2014 +0200

    parser: Report error only for private instance fields in structs
    
    Fixes bug 734787

 vala/valaparser.vala |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 89218eb..41d10ef 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2574,16 +2574,17 @@ public class Vala.Parser : CodeVisitor {
                var f = new Field (id, type, null, get_src (begin), comment);
                f.access = access;
 
-               if (parent is Struct && f.access != SymbolAccessibility.PUBLIC) {
-                       Report.error (f.source_reference, "accessibility of struct fields can only be 
`public`");
-               }
-
                set_attributes (f, attrs);
                if (ModifierFlags.STATIC in flags) {
                        f.binding = MemberBinding.STATIC;
                } else if (ModifierFlags.CLASS in flags) {
                        f.binding = MemberBinding.CLASS;
                }
+
+               if (parent is Struct && f.access != SymbolAccessibility.PUBLIC && f.binding == 
MemberBinding.INSTANCE) {
+                       Report.error (f.source_reference, "accessibility of struct fields can only be 
`public`");
+               }
+
                if (ModifierFlags.ABSTRACT in flags
                    || ModifierFlags.VIRTUAL in flags
                    || ModifierFlags.OVERRIDE in flags) {


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