]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Exclude nullable simple-type structs from gobject-property support
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 3 Sep 2019 16:29:43 +0000 (18:29 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 3 Sep 2019 21:53:33 +0000 (23:53 +0200)
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.

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

index 4ec47f0a775d2cf67a704751bd1d9df6ca4b253a..9e5190a5b51d68319016591067759eed90e2b2e1 100644 (file)
@@ -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 (file)
index 0000000..d1b4915
--- /dev/null
@@ -0,0 +1,6 @@
+public class Foo : Object {
+       public bool? bar { owned get; set; }
+}
+
+void main () {
+}
index f81921296494ddc1ab44341cc2657ee01894f6be..4a8e777a447faa5f326fb90e1907073f446d9e53 100644 (file)
@@ -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;