]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Don't allow nullable enum value as real GObject property
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 29 Mar 2022 14:33:55 +0000 (16:33 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 10 Aug 2022 13:24:58 +0000 (15:24 +0200)
It is basically a boxed integer value.

Fixes https://gitlab.gnome.org/GNOME/vala/issues/1074

tests/Makefile.am
tests/objects/property-enum-nullable.vala [new file with mode: 0644]
vala/valasemanticanalyzer.vala

index b282f1e2d800324a9c8c0af4f5a3686c96f65fec..97c3883ea97f680629dd85bf450da7d183f0d132 100644 (file)
@@ -523,6 +523,7 @@ TESTS = \
        objects/property-construct-only-write-foreign.test \
        objects/property-delegate.vala \
        objects/property-delegate-owned.vala \
+       objects/property-enum-nullable.vala \
        objects/property-gboxed-nullable.vala \
        objects/property-real-struct-assignment.vala \
        objects/property-real-struct-no-accessor.test \
diff --git a/tests/objects/property-enum-nullable.vala b/tests/objects/property-enum-nullable.vala
new file mode 100644 (file)
index 0000000..e7206e0
--- /dev/null
@@ -0,0 +1,10 @@
+enum Bar {
+       Manam;
+}
+
+class Foo : Object {
+       public Bar? bar { owned get; set; }
+}
+
+void main () {
+}
index 8b701da7fcebd13fc773a4475560c338a7409204..23f6329dd5b7b968cb449b4377bfe693d134d2b1 100644 (file)
@@ -499,6 +499,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        }
                }
 
+               if (property_type is EnumValueType) {
+                       return !property_type.nullable;
+               }
+
                if (property_type is ArrayType && ((ArrayType) property_type).element_type.type_symbol != string_type.type_symbol) {
                        return false;
                }