diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-03-21 11:14:49 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2023-03-21 11:14:49 +0100 |
commit | f8c0ce38c6954069a81561bff8207bf43a81c10f (patch) | |
tree | 3b433ecb7eaa3fb88981709d0c66834d7c65338f | |
parent | c9c112d5ed9516405a1d87f390889a7003facdbc (diff) | |
download | vala-f8c0ce38c6954069a81561bff8207bf43a81c10f.tar.gz |
vala: Owned property accessors are not allowed for non-null simple types
Additionally drop invalid g_value_take_* references for enums
-rw-r--r-- | codegen/valaccodeattribute.vala | 15 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/objects/property-owned-simple-type.test | 12 | ||||
-rw-r--r-- | vala/valapropertyaccessor.vala | 6 |
4 files changed, 19 insertions, 15 deletions
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala index 3901e65d9..74a366524 100644 --- a/codegen/valaccodeattribute.vala +++ b/codegen/valaccodeattribute.vala @@ -1337,21 +1337,6 @@ public class Vala.CCodeAttribute : AttributeCache { } else { return "g_value_take_boxed"; } - } else if (sym is Enum) { - unowned Enum en = (Enum) sym; - if (get_ccode_has_type_id (en)) { - if (en.is_flags) { - return "g_value_take_flags"; - } else { - return "g_value_take_enum"; - } - } else { - if (en.is_flags) { - return "g_value_take_uint"; - } else { - return "g_value_take_int"; - } - } } else if (sym is ErrorDomain) { return "g_value_take_boxed"; } else if (sym is Interface) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 9b005ce76..6f4c5a752 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -568,6 +568,7 @@ TESTS = \ objects/property-error.vala \ objects/property-notify.vala \ objects/property-notify-owned-getter.vala \ + objects/property-owned-simple-type.test \ objects/property-ownership.vala \ objects/property-read-only-auto.vala \ objects/property-read-only-member-write.test \ diff --git a/tests/objects/property-owned-simple-type.test b/tests/objects/property-owned-simple-type.test new file mode 100644 index 000000000..d75565bfa --- /dev/null +++ b/tests/objects/property-owned-simple-type.test @@ -0,0 +1,12 @@ +Invalid Code + +enum Bar { + FOO +} + +class Foo : Object { + public Bar bar { owned get; owned set; } +} + +void main () { +} diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala index 0fbf4d32f..72e5ce675 100644 --- a/vala/valapropertyaccessor.vala +++ b/vala/valapropertyaccessor.vala @@ -218,6 +218,12 @@ public class Vala.PropertyAccessor : Subroutine { return false; } + if (value_type.value_owned && value_type.is_non_null_simple_type ()) { + error = true; + Report.error (source_reference, "`owned' accessor not allowed for specified property type"); + return false; + } + if (context.profile == Profile.POSIX && construction) { error = true; Report.error (source_reference, "`construct' is not supported in POSIX profile"); |