[vala/staging] vala: Exclude nullable simple-type structs from gobject-property support



commit 4e695a4e374df741859651f62e9a554f55991aac
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Sep 3 18:29:43 2019 +0200

    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.

 tests/Makefile.am                                       | 1 +
 tests/objects/property-simple-type-struct-nullable.vala | 6 ++++++
 vala/valasemanticanalyzer.vala                          | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)
---
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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]