[vala/staging] codegen: Silence warning about copying if delegate doesn't carry its target



commit f0b5be755dedfa0df182a955a00280aa89b186c8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Oct 2 15:07:32 2019 +0200

    codegen: Silence warning about copying if delegate doesn't carry its target

 codegen/valaccodeattribute.vala  | 10 ++++++++++
 codegen/valaccodebasemodule.vala |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index b6dc5da86..316570273 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -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;
        }
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 548ec58a6..c110716fb 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4368,7 +4368,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");


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