]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
parser: Report error only for private instance fields in structs
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 14 Aug 2014 12:28:21 +0000 (14:28 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 14 Aug 2014 12:28:21 +0000 (14:28 +0200)
Fixes bug 734787

vala/valaparser.vala

index 89218ebdc02ec9850a9887a2ae8f43032a8355c0..41d10efafd6d8670033348dcd231837e893fb689 100644 (file)
@@ -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) {