From: Rico Tzschichholz Date: Tue, 3 Sep 2019 16:29:43 +0000 (+0200) Subject: vala: Exclude nullable simple-type structs from gobject-property support X-Git-Tag: 0.46.0~3 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=4e695a4e374df741859651f62e9a554f55991aac;p=thirdparty%2Fvala.git vala: Exclude nullable simple-type structs from gobject-property support Defining "bool? { owned get; set; }" in a GObject class resulted in: "error: The type `bool' doesn't declare a GValue take function" Fixes a regression of 3af1cfb3bf6b1d3d4a8116382e6eda702f7335bf and reverts to the old behavior for nullable simple-type structs. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 4ec47f0a7..9e5190a5b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -326,6 +326,7 @@ TESTS = \ objects/property-construct-only-write-foreign.test \ objects/property-gboxed-nullable.vala \ objects/property-real-struct-no-accessor.test \ + objects/property-simple-type-struct-nullable.vala \ objects/property-static.vala \ objects/regex.vala \ objects/signals.vala \ diff --git a/tests/objects/property-simple-type-struct-nullable.vala b/tests/objects/property-simple-type-struct-nullable.vala new file mode 100644 index 000000000..d1b4915b2 --- /dev/null +++ b/tests/objects/property-simple-type-struct-nullable.vala @@ -0,0 +1,6 @@ +public class Foo : Object { + public bool? bar { owned get; set; } +} + +void main () { +} diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index f81921296..4a8e777a4 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -451,7 +451,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { public bool is_gobject_property_type (DataType property_type) { var st = property_type.data_type as Struct; if (st != null) { - if (st.get_attribute_bool ("CCode", "has_type_id", true)) { + if (!st.is_simple_type () && st.get_attribute_bool ("CCode", "has_type_id", true)) { // Allow GType-based struct types } else if (property_type.nullable) { return false;