]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girparser: Classes are considered sealed when there were no fields found
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 16 Apr 2023 12:24:25 +0000 (14:24 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 16 Apr 2023 12:24:25 +0000 (14:24 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1036

vala/valaclass.vala
vala/valagirparser.vala

index 436a6b3cfe3f9d6c9b33ff9e84f38957c980477e..a87bb4240de12e591be8f48b9a28ed44e69a6d67 100644 (file)
@@ -592,7 +592,7 @@ public class Vala.Class : ObjectTypeSymbol {
                        add_constructor (c);
                }
 
-               if (base_class != null && base_class.is_sealed) {
+               if (!external_package && base_class != null && base_class.is_sealed) {
                        error = true;
                        Report.error (source_reference, "`%s' cannot inherit from sealed class `%s'", get_full_name (), base_class.get_full_name ());
                }
index 70206da6c9b859c99e6056fa9f261e0ed103472f..d86e19f1676b63661eae4cc24f8e904ec51f3645 100644 (file)
@@ -3137,6 +3137,16 @@ public class Vala.GirParser : CodeVisitor {
                        pop_metadata ();
                }
 
+               // There is no instance field therefore this type might be final/sealed
+               if (first_field && !cl.is_abstract && !(cl.is_opaque || cl.is_sealed)) {
+                       if (!cl.is_compact
+                           && !metadata.has_argument (ArgumentType.ABSTRACT)
+                           && !metadata.has_argument (ArgumentType.COMPACT)
+                           && !metadata.has_argument (ArgumentType.SEALED)) {
+                               cl.is_sealed = true;
+                       }
+               }
+
                pop_node ();
                end_element ("class");
        }