]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Silence warning about copying if delegate doesn't carry its target
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 2 Oct 2019 13:07:32 +0000 (15:07 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 5 Oct 2019 11:45:55 +0000 (13:45 +0200)
codegen/valaccodeattribute.vala
codegen/valaccodebasemodule.vala

index 5728fb46995ba0347466ae36ffd9fff05377e3b0..48ae6c41e125f0c121346c0ac6b73e461995d893 100644 (file)
@@ -1484,6 +1484,16 @@ public class Vala.CCodeAttribute : AttributeCache {
                } else if (node is Callable) {
                        unowned DelegateType? delegate_type = ((Callable) node).return_type as DelegateType;
                        return delegate_type != null && delegate_type.delegate_symbol.has_target;
+               } else if (node is Property) {
+                       unowned DelegateType? delegate_type = ((Property) node).property_type as DelegateType;
+                       return delegate_type != null && delegate_type.delegate_symbol.has_target;
+               } else if (node is PropertyAccessor) {
+                       return get_ccode_delegate_target (((PropertyAccessor) node).prop);
+               } else if (node is Expression) {
+                       unowned Symbol? symbol = ((Expression) node).symbol_reference;
+                       if (symbol != null) {
+                               return get_ccode_delegate_target (symbol);
+                       }
                }
                return false;
        }
index d2e4dbd233109b53d7fa49e29af8a0204012bfc1..9963b83c09797ceaa3c213d619da60e7df63c569 100644 (file)
@@ -4392,7 +4392,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                if (type is DelegateType) {
                        var delegate_type = (DelegateType) type;
-                       if (delegate_type.delegate_symbol.has_target && !context.deprecated) {
+                       if (get_ccode_delegate_target (node) && delegate_type.delegate_symbol.has_target && !context.deprecated) {
                                Report.deprecated (node.source_reference, "copying delegates is not supported");
                        }
                        result.delegate_target_destroy_notify_cvalue = new CCodeConstant ("NULL");