From: Rico Tzschichholz Date: Tue, 29 Mar 2022 14:33:55 +0000 (+0200) Subject: vala: Don't allow nullable enum value as real GObject property X-Git-Tag: 0.48.25~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d37bad7f2047e855591a81b853eba66b3f1869f;p=thirdparty%2Fvala.git vala: Don't allow nullable enum value as real GObject property It is basically a boxed integer value. Fixes https://gitlab.gnome.org/GNOME/vala/issues/1074 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index b282f1e2d..97c3883ea 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..e7206e060 --- /dev/null +++ b/tests/objects/property-enum-nullable.vala @@ -0,0 +1,10 @@ +enum Bar { + Manam; +} + +class Foo : Object { + public Bar? bar { owned get; set; } +} + +void main () { +} diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 8b701da7f..23f6329dd 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -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; }