From 3506a9615e131c9e6c270484afdf1e0d2da32515 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 5 Oct 2015 17:56:58 +0300 Subject: [PATCH] Don't write default values of flags, provide sensible defaults --- .../serialization/DescriptorSerializer.java | 49 ++-- .../kotlin/serialization/DebugProtoBuf.java | 226 +++++++++--------- core/deserialization/src/descriptors.proto | 32 +-- .../kotlin/serialization/ProtoBuf.java | 158 ++++++------ 4 files changed, 230 insertions(+), 235 deletions(-) diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java index 91c22277def..376f1c2bb6d 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java @@ -100,7 +100,9 @@ public class DescriptorSerializer { int flags = Flags.getClassFlags(hasAnnotations(classDescriptor), classDescriptor.getVisibility(), classDescriptor.getModality(), classDescriptor.getKind(), classDescriptor.isInner(), classDescriptor.isCompanionObject()); - builder.setFlags(flags); + if (flags != builder.getFlags()) { + builder.setFlags(flags); + } builder.setFqName(getClassId(classDescriptor)); @@ -200,18 +202,13 @@ public class DescriptorSerializer { } } - builder.setFlags(Flags.getPropertyFlags( - hasAnnotations, - descriptor.getVisibility(), - descriptor.getModality(), - descriptor.getKind(), - descriptor.isVar(), - hasGetter, - hasSetter, - hasConstant, - isConst, - lateInit - )); + int flags = Flags.getPropertyFlags( + hasAnnotations, descriptor.getVisibility(), descriptor.getModality(), descriptor.getKind(), descriptor.isVar(), + hasGetter, hasSetter, hasConstant, isConst, lateInit + ); + if (flags != builder.getFlags()) { + builder.setFlags(flags); + } builder.setName(getSimpleNameIndex(descriptor.getName())); @@ -237,14 +234,13 @@ public class DescriptorSerializer { DescriptorSerializer local = createChildSerializer(); - builder.setFlags(Flags.getFunctionFlags( - hasAnnotations(descriptor), - descriptor.getVisibility(), - descriptor.getModality(), - descriptor.getKind(), - descriptor.isOperator(), - descriptor.isInfix() - )); + int flags = Flags.getFunctionFlags( + hasAnnotations(descriptor), descriptor.getVisibility(), descriptor.getModality(), descriptor.getKind(), + descriptor.isOperator(), descriptor.isInfix() + ); + if (flags != builder.getFlags()) { + builder.setFlags(flags); + } builder.setName(getSimpleNameIndex(descriptor.getName())); @@ -275,11 +271,10 @@ public class DescriptorSerializer { DescriptorSerializer local = createChildSerializer(); - builder.setFlags(Flags.getConstructorFlags( - hasAnnotations(descriptor), - descriptor.getVisibility(), - !descriptor.isPrimary() - )); + int flags = Flags.getConstructorFlags(hasAnnotations(descriptor), descriptor.getVisibility(), !descriptor.isPrimary()); + if (flags != builder.getFlags()) { + builder.setFlags(flags); + } for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) { builder.addValueParameter(local.valueParameter(valueParameterDescriptor)); @@ -304,7 +299,7 @@ public class DescriptorSerializer { ProtoBuf.ValueParameter.Builder builder = ProtoBuf.ValueParameter.newBuilder(); int flags = Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue()); - if (flags != 0) { + if (flags != builder.getFlags()) { builder.setFlags(flags); } diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java b/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java index da37279bf3a..0b624aae007 100644 --- a/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java +++ b/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java @@ -8557,28 +8557,28 @@ public final class DebugProtoBuf { com.google.protobuf.GeneratedMessage. ExtendableMessageOrBuilder { - // optional int32 flags = 1 [default = 0]; + // optional int32 flags = 1 [default = 6]; /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
*/ boolean hasFlags(); /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
@@ -9102,17 +9102,17 @@ public final class DebugProtoBuf { } private int bitField0_; - // optional int32 flags = 1 [default = 0]; + // optional int32 flags = 1 [default = 6]; public static final int FLAGS_FIELD_NUMBER = 1; private int flags_; /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
@@ -9121,13 +9121,13 @@ public final class DebugProtoBuf { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
@@ -9397,7 +9397,7 @@ public final class DebugProtoBuf { private int enumEntryMemoizedSerializedSize = -1; private void initFields() { - flags_ = 0; + flags_ = 6; fqName_ = 0; companionObjectName_ = 0; typeParameter_ = java.util.Collections.emptyList(); @@ -9691,7 +9691,7 @@ public final class DebugProtoBuf { public Builder clear() { super.clear(); - flags_ = 0; + flags_ = 6; bitField0_ = (bitField0_ & ~0x00000001); fqName_ = 0; bitField0_ = (bitField0_ & ~0x00000002); @@ -10067,16 +10067,16 @@ public final class DebugProtoBuf { } private int bitField0_; - // optional int32 flags = 1 [default = 0]; - private int flags_ ; + // optional int32 flags = 1 [default = 6]; + private int flags_ = 6; /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
@@ -10085,13 +10085,13 @@ public final class DebugProtoBuf { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
@@ -10100,13 +10100,13 @@ public final class DebugProtoBuf { return flags_; } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
@@ -10118,20 +10118,20 @@ public final class DebugProtoBuf { return this; } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
*/ public Builder clearFlags() { bitField0_ = (bitField0_ & ~0x00000001); - flags_ = 0; + flags_ = 6; onChanged(); return this; } @@ -12624,9 +12624,9 @@ public final class DebugProtoBuf { com.google.protobuf.GeneratedMessage. ExtendableMessageOrBuilder { - // optional int32 flags = 1; + // optional int32 flags = 1 [default = 6]; /** - * optional int32 flags = 1; + * optional int32 flags = 1 [default = 6]; * *
      *
@@ -12637,7 +12637,7 @@ public final class DebugProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -12780,11 +12780,11 @@ public final class DebugProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 6];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -12797,7 +12797,7 @@ public final class DebugProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -12847,7 +12847,7 @@ public final class DebugProtoBuf {
     }
 
     private void initFields() {
-      flags_ = 0;
+      flags_ = 6;
       valueParameter_ = java.util.Collections.emptyList();
     }
     private byte memoizedIsInitialized = -1;
@@ -13017,7 +13017,7 @@ public final class DebugProtoBuf {
 
       public Builder clear() {
         super.clear();
-        flags_ = 0;
+        flags_ = 6;
         bitField0_ = (bitField0_ & ~0x00000001);
         if (valueParameterBuilder_ == null) {
           valueParameter_ = java.util.Collections.emptyList();
@@ -13149,10 +13149,10 @@ public final class DebugProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
-      private int flags_ ;
+      // optional int32 flags = 1 [default = 6];
+      private int flags_ = 6;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -13165,7 +13165,7 @@ public final class DebugProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -13178,7 +13178,7 @@ public final class DebugProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -13194,7 +13194,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -13205,7 +13205,7 @@ public final class DebugProtoBuf {
        */
       public Builder clearFlags() {
         bitField0_ = (bitField0_ & ~0x00000001);
-        flags_ = 0;
+        flags_ = 6;
         onChanged();
         return this;
       }
@@ -13465,9 +13465,9 @@ public final class DebugProtoBuf {
       com.google.protobuf.GeneratedMessage.
           ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 6];
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -13481,7 +13481,7 @@ public final class DebugProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -13732,11 +13732,11 @@ public final class DebugProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 6];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -13752,7 +13752,7 @@ public final class DebugProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -13901,7 +13901,7 @@ public final class DebugProtoBuf {
     }
 
     private void initFields() {
-      flags_ = 0;
+      flags_ = 6;
       name_ = 0;
       returnType_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.Type.getDefaultInstance();
       typeParameter_ = java.util.Collections.emptyList();
@@ -14130,7 +14130,7 @@ public final class DebugProtoBuf {
 
       public Builder clear() {
         super.clear();
-        flags_ = 0;
+        flags_ = 6;
         bitField0_ = (bitField0_ & ~0x00000001);
         name_ = 0;
         bitField0_ = (bitField0_ & ~0x00000002);
@@ -14370,10 +14370,10 @@ public final class DebugProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
-      private int flags_ ;
+      // optional int32 flags = 1 [default = 6];
+      private int flags_ = 6;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -14389,7 +14389,7 @@ public final class DebugProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -14405,7 +14405,7 @@ public final class DebugProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -14424,7 +14424,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -14438,7 +14438,7 @@ public final class DebugProtoBuf {
        */
       public Builder clearFlags() {
         bitField0_ = (bitField0_ & ~0x00000001);
-        flags_ = 0;
+        flags_ = 6;
         onChanged();
         return this;
       }
@@ -15205,9 +15205,9 @@ public final class DebugProtoBuf {
       com.google.protobuf.GeneratedMessage.
           ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 262];
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -15225,7 +15225,7 @@ public final class DebugProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -15517,11 +15517,11 @@ public final class DebugProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 262];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -15541,7 +15541,7 @@ public final class DebugProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -15728,7 +15728,7 @@ public final class DebugProtoBuf {
     }
 
     private void initFields() {
-      flags_ = 0;
+      flags_ = 262;
       name_ = 0;
       returnType_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.Type.getDefaultInstance();
       typeParameter_ = java.util.Collections.emptyList();
@@ -15973,7 +15973,7 @@ public final class DebugProtoBuf {
 
       public Builder clear() {
         super.clear();
-        flags_ = 0;
+        flags_ = 262;
         bitField0_ = (bitField0_ & ~0x00000001);
         name_ = 0;
         bitField0_ = (bitField0_ & ~0x00000002);
@@ -16207,10 +16207,10 @@ public final class DebugProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
-      private int flags_ ;
+      // optional int32 flags = 1 [default = 262];
+      private int flags_ = 262;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -16230,7 +16230,7 @@ public final class DebugProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -16250,7 +16250,7 @@ public final class DebugProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -16273,7 +16273,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -16291,7 +16291,7 @@ public final class DebugProtoBuf {
        */
       public Builder clearFlags() {
         bitField0_ = (bitField0_ & ~0x00000001);
-        flags_ = 0;
+        flags_ = 262;
         onChanged();
         return this;
       }
@@ -17033,9 +17033,9 @@ public final class DebugProtoBuf {
       com.google.protobuf.GeneratedMessage.
           ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 0];
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -17045,7 +17045,7 @@ public final class DebugProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -17220,11 +17220,11 @@ public final class DebugProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 0];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -17236,7 +17236,7 @@ public final class DebugProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -17654,10 +17654,10 @@ public final class DebugProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
+      // optional int32 flags = 1 [default = 0];
       private int flags_ ;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -17669,7 +17669,7 @@ public final class DebugProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -17681,7 +17681,7 @@ public final class DebugProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -17696,7 +17696,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -18123,7 +18123,7 @@ public final class DebugProtoBuf {
       "eParameter.Variance:\003INV\022=\n\013upper_bound\030" +
       "\005 \003(\0132(.org.jetbrains.kotlin.serializati" +
       "on.Type\"$\n\010Variance\022\006\n\002IN\020\000\022\007\n\003OUT\020\001\022\007\n\003",
-      "INV\020\002\"\343\004\n\005Class\022\020\n\005flags\030\001 \001(\005:\0010\022\025\n\007fq_" +
+      "INV\020\002\"\343\004\n\005Class\022\020\n\005flags\030\001 \001(\005:\0016\022\025\n\007fq_" +
       "name\030\003 \002(\005B\004\220\265\030\001\022#\n\025companion_object_nam" +
       "e\030\004 \001(\005B\004\210\265\030\001\022I\n\016type_parameter\030\005 \003(\01321." +
       "org.jetbrains.kotlin.serialization.TypeP" +
@@ -18142,39 +18142,39 @@ public final class DebugProtoBuf {
       "ion\030\003 \003(\0132,.org.jetbrains.kotlin.seriali" +
       "zation.Function\022>\n\010property\030\004 \003(\0132,.org." +
       "jetbrains.kotlin.serialization.Property*" +
-      "\005\010d\020\310\001\"p\n\013Constructor\022\r\n\005flags\030\001 \001(\005\022K\n\017",
-      "value_parameter\030\002 \003(\01322.org.jetbrains.ko" +
-      "tlin.serialization.ValueParameter*\005\010d\020\310\001" +
-      "\"\314\002\n\010Function\022\r\n\005flags\030\001 \001(\005\022\022\n\004name\030\002 \002" +
-      "(\005B\004\210\265\030\001\022=\n\013return_type\030\003 \002(\0132(.org.jetb" +
-      "rains.kotlin.serialization.Type\022I\n\016type_" +
-      "parameter\030\004 \003(\01321.org.jetbrains.kotlin.s" +
-      "erialization.TypeParameter\022?\n\rreceiver_t" +
-      "ype\030\005 \001(\0132(.org.jetbrains.kotlin.seriali" +
-      "zation.Type\022K\n\017value_parameter\030\006 \003(\01322.o" +
-      "rg.jetbrains.kotlin.serialization.ValueP",
-      "arameter*\005\010d\020\310\001\"\377\002\n\010Property\022\r\n\005flags\030\001 " +
-      "\001(\005\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022=\n\013return_type\030\003" +
-      " \002(\0132(.org.jetbrains.kotlin.serializatio" +
-      "n.Type\022I\n\016type_parameter\030\004 \003(\01321.org.jet" +
-      "brains.kotlin.serialization.TypeParamete" +
-      "r\022?\n\rreceiver_type\030\005 \001(\0132(.org.jetbrains" +
-      ".kotlin.serialization.Type\022R\n\026setter_val" +
-      "ue_parameter\030\006 \001(\01322.org.jetbrains.kotli" +
-      "n.serialization.ValueParameter\022\024\n\014getter" +
-      "_flags\030\007 \001(\005\022\024\n\014setter_flags\030\010 \001(\005*\005\010d\020\310",
-      "\001\"\271\001\n\016ValueParameter\022\r\n\005flags\030\001 \001(\005\022\022\n\004n" +
-      "ame\030\002 \002(\005B\004\210\265\030\001\0226\n\004type\030\003 \002(\0132(.org.jetb" +
-      "rains.kotlin.serialization.Type\022E\n\023varar" +
-      "g_element_type\030\004 \001(\0132(.org.jetbrains.kot" +
-      "lin.serialization.Type*\005\010d\020\310\001*9\n\010Modalit" +
-      "y\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006" +
-      "SEALED\020\003*b\n\nVisibility\022\014\n\010INTERNAL\020\000\022\013\n\007" +
-      "PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017" +
-      "PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKi" +
-      "nd\022\017\n\013DECLARATION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016",
-      "\n\nDELEGATION\020\002\022\017\n\013SYNTHESIZED\020\003B\022B\rDebug" +
-      "ProtoBuf\210\001\000"
+      "\005\010d\020\310\001\"s\n\013Constructor\022\020\n\005flags\030\001 \001(\005:\0016\022",
+      "K\n\017value_parameter\030\002 \003(\01322.org.jetbrains" +
+      ".kotlin.serialization.ValueParameter*\005\010d" +
+      "\020\310\001\"\317\002\n\010Function\022\020\n\005flags\030\001 \001(\005:\0016\022\022\n\004na" +
+      "me\030\002 \002(\005B\004\210\265\030\001\022=\n\013return_type\030\003 \002(\0132(.or" +
+      "g.jetbrains.kotlin.serialization.Type\022I\n" +
+      "\016type_parameter\030\004 \003(\01321.org.jetbrains.ko" +
+      "tlin.serialization.TypeParameter\022?\n\rrece" +
+      "iver_type\030\005 \001(\0132(.org.jetbrains.kotlin.s" +
+      "erialization.Type\022K\n\017value_parameter\030\006 \003" +
+      "(\01322.org.jetbrains.kotlin.serialization.",
+      "ValueParameter*\005\010d\020\310\001\"\204\003\n\010Property\022\022\n\005fl" +
+      "ags\030\001 \001(\005:\003262\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\022=\n\013re" +
+      "turn_type\030\003 \002(\0132(.org.jetbrains.kotlin.s" +
+      "erialization.Type\022I\n\016type_parameter\030\004 \003(" +
+      "\01321.org.jetbrains.kotlin.serialization.T" +
+      "ypeParameter\022?\n\rreceiver_type\030\005 \001(\0132(.or" +
+      "g.jetbrains.kotlin.serialization.Type\022R\n" +
+      "\026setter_value_parameter\030\006 \001(\01322.org.jetb" +
+      "rains.kotlin.serialization.ValueParamete" +
+      "r\022\024\n\014getter_flags\030\007 \001(\005\022\024\n\014setter_flags\030",
+      "\010 \001(\005*\005\010d\020\310\001\"\274\001\n\016ValueParameter\022\020\n\005flags" +
+      "\030\001 \001(\005:\0010\022\022\n\004name\030\002 \002(\005B\004\210\265\030\001\0226\n\004type\030\003 " +
+      "\002(\0132(.org.jetbrains.kotlin.serialization" +
+      ".Type\022E\n\023vararg_element_type\030\004 \001(\0132(.org" +
+      ".jetbrains.kotlin.serialization.Type*\005\010d" +
+      "\020\310\001*9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010" +
+      "ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010" +
+      "INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n" +
+      "\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL" +
+      "\020\005*Q\n\nMemberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAK",
+      "E_OVERRIDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESI" +
+      "ZED\020\003B\022B\rDebugProtoBuf\210\001\000"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
diff --git a/core/deserialization/src/descriptors.proto b/core/deserialization/src/descriptors.proto
index c5bbca8396c..e2b5cc73a4d 100644
--- a/core/deserialization/src/descriptors.proto
+++ b/core/deserialization/src/descriptors.proto
@@ -156,13 +156,13 @@ message Class {
   }
 
   /*
+    hasAnnotations
     Visibility
     Modality
-    hasAnnotations
     ClassKind
     isInner
   */
-  optional int32 flags = 1 [default = 0 /*internal final class, no annotations*/];
+  optional int32 flags = 1 [default = 6 /* public final class, no annotations */];
 
   required int32 fq_name = 3 [(fq_name_id_in_table) = true];
 
@@ -195,7 +195,7 @@ message Constructor {
     Visibility
     isSecondary
   */
-  optional int32 flags = 1;
+  optional int32 flags = 1 [default = 6];
 
   repeated ValueParameter value_parameter = 2;
 
@@ -211,7 +211,7 @@ message Function {
     isOperator
     isInfix
   */
-  optional int32 flags = 1;
+  optional int32 flags = 1 [default = 6];
 
   required int32 name = 2 [(name_id_in_table) = true];
 
@@ -239,7 +239,7 @@ message Property {
     lateinit
     hasConstant
   */
-  optional int32 flags = 1;
+  optional int32 flags = 1 [default = 262 /* public (6) final property with getter (256) */];
 
   required int32 name = 2 [(name_id_in_table) = true];
 
@@ -268,7 +268,7 @@ message ValueParameter {
     declaresDefault
     hasAnnotations
   */
-  optional int32 flags = 1;
+  optional int32 flags = 1 [default = 0];
 
   required int32 name = 2 [(name_id_in_table) = true];
 
@@ -281,20 +281,20 @@ message ValueParameter {
 
 enum Modality {
   // 2 bits
-  FINAL = 0x00;
-  OPEN = 0x01;
-  ABSTRACT = 0x02;
-  SEALED = 0x03;
+  FINAL = 0;
+  OPEN = 1;
+  ABSTRACT = 2;
+  SEALED = 3;
 }
 
 enum Visibility {
   // 3 bits
-  INTERNAL = 0x00;
-  PRIVATE = 0x01;
-  PROTECTED = 0x02;
-  PUBLIC = 0x03;
-  PRIVATE_TO_THIS = 0x04;
-  LOCAL = 0x05;
+  INTERNAL = 0;
+  PRIVATE = 1;
+  PROTECTED = 2;
+  PUBLIC = 3;
+  PRIVATE_TO_THIS = 4;
+  LOCAL = 5;
 }
 
 enum MemberKind {
diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
index ffe70df3370..49d709a179d 100644
--- a/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
+++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
@@ -6729,28 +6729,28 @@ public final class ProtoBuf {
        com.google.protobuf.GeneratedMessageLite.
             ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1 [default = 0];
+    // optional int32 flags = 1 [default = 6];
     /**
-     * optional int32 flags = 1 [default = 0];
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
*/ boolean hasFlags(); /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
@@ -7177,17 +7177,17 @@ public final class ProtoBuf { } private int bitField0_; - // optional int32 flags = 1 [default = 0]; + // optional int32 flags = 1 [default = 6]; public static final int FLAGS_FIELD_NUMBER = 1; private int flags_; /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
@@ -7196,13 +7196,13 @@ public final class ProtoBuf { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
      *
+     *hasAnnotations
      *Visibility
      *Modality
-     *hasAnnotations
      *ClassKind
      *isInner
      * 
@@ -7472,7 +7472,7 @@ public final class ProtoBuf { private int enumEntryMemoizedSerializedSize = -1; private void initFields() { - flags_ = 0; + flags_ = 6; fqName_ = 0; companionObjectName_ = 0; typeParameter_ = java.util.Collections.emptyList(); @@ -7734,7 +7734,7 @@ public final class ProtoBuf { public Builder clear() { super.clear(); - flags_ = 0; + flags_ = 6; bitField0_ = (bitField0_ & ~0x00000001); fqName_ = 0; bitField0_ = (bitField0_ & ~0x00000002); @@ -7974,16 +7974,16 @@ public final class ProtoBuf { } private int bitField0_; - // optional int32 flags = 1 [default = 0]; - private int flags_ ; + // optional int32 flags = 1 [default = 6]; + private int flags_ = 6; /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
@@ -7992,13 +7992,13 @@ public final class ProtoBuf { return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
@@ -8007,13 +8007,13 @@ public final class ProtoBuf { return flags_; } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
@@ -8025,20 +8025,20 @@ public final class ProtoBuf { return this; } /** - * optional int32 flags = 1 [default = 0]; + * optional int32 flags = 1 [default = 6]; * *
        *
+       *hasAnnotations
        *Visibility
        *Modality
-       *hasAnnotations
        *ClassKind
        *isInner
        * 
*/ public Builder clearFlags() { bitField0_ = (bitField0_ & ~0x00000001); - flags_ = 0; + flags_ = 6; return this; } @@ -9592,9 +9592,9 @@ public final class ProtoBuf { com.google.protobuf.GeneratedMessageLite. ExtendableMessageOrBuilder { - // optional int32 flags = 1; + // optional int32 flags = 1 [default = 6]; /** - * optional int32 flags = 1; + * optional int32 flags = 1 [default = 6]; * *
      *
@@ -9605,7 +9605,7 @@ public final class ProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -9717,11 +9717,11 @@ public final class ProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 6];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -9734,7 +9734,7 @@ public final class ProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -9784,7 +9784,7 @@ public final class ProtoBuf {
     }
 
     private void initFields() {
-      flags_ = 0;
+      flags_ = 6;
       valueParameter_ = java.util.Collections.emptyList();
     }
     private byte memoizedIsInitialized = -1;
@@ -9926,7 +9926,7 @@ public final class ProtoBuf {
 
       public Builder clear() {
         super.clear();
-        flags_ = 0;
+        flags_ = 6;
         bitField0_ = (bitField0_ & ~0x00000001);
         valueParameter_ = java.util.Collections.emptyList();
         bitField0_ = (bitField0_ & ~0x00000002);
@@ -10018,10 +10018,10 @@ public final class ProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
-      private int flags_ ;
+      // optional int32 flags = 1 [default = 6];
+      private int flags_ = 6;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -10034,7 +10034,7 @@ public final class ProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -10047,7 +10047,7 @@ public final class ProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -10063,7 +10063,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -10074,7 +10074,7 @@ public final class ProtoBuf {
        */
       public Builder clearFlags() {
         bitField0_ = (bitField0_ & ~0x00000001);
-        flags_ = 0;
+        flags_ = 6;
         
         return this;
       }
@@ -10219,9 +10219,9 @@ public final class ProtoBuf {
        com.google.protobuf.GeneratedMessageLite.
             ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 6];
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -10235,7 +10235,7 @@ public final class ProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -10437,11 +10437,11 @@ public final class ProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 6];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -10457,7 +10457,7 @@ public final class ProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 6];
      *
      * 
      *
@@ -10594,7 +10594,7 @@ public final class ProtoBuf {
     }
 
     private void initFields() {
-      flags_ = 0;
+      flags_ = 6;
       name_ = 0;
       returnType_ = org.jetbrains.kotlin.serialization.ProtoBuf.Type.getDefaultInstance();
       typeParameter_ = java.util.Collections.emptyList();
@@ -10792,7 +10792,7 @@ public final class ProtoBuf {
 
       public Builder clear() {
         super.clear();
-        flags_ = 0;
+        flags_ = 6;
         bitField0_ = (bitField0_ & ~0x00000001);
         name_ = 0;
         bitField0_ = (bitField0_ & ~0x00000002);
@@ -10952,10 +10952,10 @@ public final class ProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
-      private int flags_ ;
+      // optional int32 flags = 1 [default = 6];
+      private int flags_ = 6;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -10971,7 +10971,7 @@ public final class ProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -10987,7 +10987,7 @@ public final class ProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -11006,7 +11006,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 6];
        *
        * 
        *
@@ -11020,7 +11020,7 @@ public final class ProtoBuf {
        */
       public Builder clearFlags() {
         bitField0_ = (bitField0_ & ~0x00000001);
-        flags_ = 0;
+        flags_ = 6;
         
         return this;
       }
@@ -11445,9 +11445,9 @@ public final class ProtoBuf {
        com.google.protobuf.GeneratedMessageLite.
             ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 262];
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -11465,7 +11465,7 @@ public final class ProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -11714,11 +11714,11 @@ public final class ProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 262];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -11738,7 +11738,7 @@ public final class ProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 262];
      *
      * 
      *
@@ -11907,7 +11907,7 @@ public final class ProtoBuf {
     }
 
     private void initFields() {
-      flags_ = 0;
+      flags_ = 262;
       name_ = 0;
       returnType_ = org.jetbrains.kotlin.serialization.ProtoBuf.Type.getDefaultInstance();
       typeParameter_ = java.util.Collections.emptyList();
@@ -12121,7 +12121,7 @@ public final class ProtoBuf {
 
       public Builder clear() {
         super.clear();
-        flags_ = 0;
+        flags_ = 262;
         bitField0_ = (bitField0_ & ~0x00000001);
         name_ = 0;
         bitField0_ = (bitField0_ & ~0x00000002);
@@ -12291,10 +12291,10 @@ public final class ProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
-      private int flags_ ;
+      // optional int32 flags = 1 [default = 262];
+      private int flags_ = 262;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -12314,7 +12314,7 @@ public final class ProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -12334,7 +12334,7 @@ public final class ProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -12357,7 +12357,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 262];
        *
        * 
        *
@@ -12375,7 +12375,7 @@ public final class ProtoBuf {
        */
       public Builder clearFlags() {
         bitField0_ = (bitField0_ & ~0x00000001);
-        flags_ = 0;
+        flags_ = 262;
         
         return this;
       }
@@ -12834,9 +12834,9 @@ public final class ProtoBuf {
        com.google.protobuf.GeneratedMessageLite.
             ExtendableMessageOrBuilder {
 
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 0];
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -12846,7 +12846,7 @@ public final class ProtoBuf {
      */
     boolean hasFlags();
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -12992,11 +12992,11 @@ public final class ProtoBuf {
     }
 
     private int bitField0_;
-    // optional int32 flags = 1;
+    // optional int32 flags = 1 [default = 0];
     public static final int FLAGS_FIELD_NUMBER = 1;
     private int flags_;
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -13008,7 +13008,7 @@ public final class ProtoBuf {
       return ((bitField0_ & 0x00000001) == 0x00000001);
     }
     /**
-     * optional int32 flags = 1;
+     * optional int32 flags = 1 [default = 0];
      *
      * 
      *
@@ -13353,10 +13353,10 @@ public final class ProtoBuf {
       }
       private int bitField0_;
 
-      // optional int32 flags = 1;
+      // optional int32 flags = 1 [default = 0];
       private int flags_ ;
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -13368,7 +13368,7 @@ public final class ProtoBuf {
         return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -13380,7 +13380,7 @@ public final class ProtoBuf {
         return flags_;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *
@@ -13395,7 +13395,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * optional int32 flags = 1;
+       * optional int32 flags = 1 [default = 0];
        *
        * 
        *