[vala/wip/issue/370: 1/2] Improvements




commit 35ee8adab28834bf6bf8255f0caffe0cf8f461eb
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Sep 21 14:27:30 2021 +0200

    Improvements

 vala/valanamespace.vala | 53 -------------------------------------------------
 vala/valaparser.vala    | 42 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 54 deletions(-)
---
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index 8dc8b9069..d62babb63 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -160,59 +160,6 @@ public class Vala.Namespace : Symbol {
                        cl.access = SymbolAccessibility.INTERNAL;
                }
 
-               if (cl.is_partial) {
-                       var old_cl = scope.lookup (cl.name) as Class;
-                       if (old_cl != null && old_cl.is_partial) {
-                               if (cl.access != old_cl.access) {
-                                       Report.error (cl.source_reference, "partial declarations of `%s' have 
conflicting accessiblity modifiers".printf (cl.name));
-                                       cl.error = true;
-                                       return;
-                               }
-                               if (cl.is_abstract != old_cl.is_abstract) {
-                                       Report.error (cl.source_reference, "partial declarations of `%s' have 
conflicting abstract modifiers".printf (cl.name));
-                                       cl.error = true;
-                                       return;
-                               }
-
-                               foreach (Class cls in cl.get_classes ()) {
-                                       old_cl.add_class (cls);
-                               }
-                               foreach (Struct st in cl.get_structs ()) {
-                                       old_cl.add_struct (st);
-                               }
-                               foreach (Delegate d in cl.get_delegates ()) {
-                                       old_cl.add_delegate (d);
-                               }
-                               foreach (Enum en in cl.get_enums ()) {
-                                       old_cl.add_enum (en);
-                               }
-                               foreach (Constant c in cl.get_constants ()) {
-                                       old_cl.add_constant (c);
-                               }
-                               foreach (Field f in cl.get_fields ()) {
-                                       old_cl.add_field (f);
-                               }
-                               foreach (Method m in cl.get_methods ()) {
-                                       if (m != cl.default_construction_method) {
-                                               old_cl.add_method (m);
-                                       }
-                               }
-                               foreach (Property prop in cl.get_properties ()) {
-                                       //FIXME old_cl.add_property (prop);
-                               }
-                               foreach (Signal sig in cl.get_signals ()) {
-                                       old_cl.add_signal (sig);
-                               }
-                               foreach (Attribute a in cl.attributes) {
-                                       if (old_cl.get_attribute (a.name) == null) {
-                                               old_cl.attributes.append(a);
-                                       }
-                               }
-
-                               return;
-                       }
-               }
-
                if (cl.owner == null) {
                        cl.source_reference.file.add_node (cl);
                }
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 0aa50e7d7..b0b820fd1 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2735,8 +2735,8 @@ public class Vala.Parser : CodeVisitor {
                        case TokenType.NAMESPACE:
                        case TokenType.NEW:
                        case TokenType.OVERRIDE:
-                       case TokenType.PRIVATE:
                        case TokenType.PARTIAL:
+                       case TokenType.PRIVATE:
                        case TokenType.PROTECTED:
                        case TokenType.PUBLIC:
                        case TokenType.SEALED:
@@ -2846,11 +2846,51 @@ public class Vala.Parser : CodeVisitor {
                        cl.is_sealed = true;
                }
                if (ModifierFlags.PARTIAL in flags) {
+                       if (!context.experimental) {
+                               Report.warning (cl.source_reference, "`partial' classes are experimental");
+                       }
                        cl.is_partial = true;
                }
                if (ModifierFlags.EXTERN in flags) {
                        cl.is_extern = true;
                }
+
+               var old_cl = parent.scope.lookup (cl.name) as Class;
+               if (old_cl != null && old_cl.is_partial) {
+                       if (cl.is_partial != old_cl.is_partial) {
+                               Report.error (cl.source_reference, "conflicting partial and not partial 
declarations of `%s'".printf (cl.name));
+                               cl.error = true;
+                       }
+                       if (cl.access != old_cl.access) {
+                               Report.error (cl.source_reference, "partial declarations of `%s' have 
conflicting accessiblity modifiers".printf (cl.name));
+                               cl.error = true;
+                       }
+                       if (cl.is_abstract != old_cl.is_abstract) {
+                               Report.error (cl.source_reference, "partial declarations of `%s' have 
conflicting abstract modifiers".printf (cl.name));
+                               cl.error = true;
+                       }
+                       if (cl.is_sealed != old_cl.is_sealed) {
+                               Report.error (cl.source_reference, "partial declarations of `%s' have 
conflicting sealed modifiers".printf (cl.name));
+                               cl.error = true;
+                       }
+                       if (cl.error) {
+                               Report.notice (old_cl.source_reference, "previous declaration of `%s' was 
here", old_cl.name);
+                               return;
+                       }
+
+                       set_attributes (old_cl, attrs);
+                       foreach (TypeParameter type_param in type_param_list) {
+                               old_cl.add_type_parameter (type_param);
+                       }
+                       foreach (DataType base_type in base_types) {
+                               old_cl.add_base_type (base_type);
+                       }
+
+                       parse_declarations (old_cl);
+
+                       return;
+               }
+
                set_attributes (cl, attrs);
                foreach (TypeParameter type_param in type_param_list) {
                        cl.add_type_parameter (type_param);


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