]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve copy of required attributes from delegate to lamdba method
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 17 Mar 2020 14:26:36 +0000 (15:26 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 24 Mar 2020 08:50:25 +0000 (09:50 +0100)
codegen/valaccodebasemodule.vala
vala/valalambdaexpression.vala

index 9ae993be83803435d3f900ea11deccf7b9bb6c8b..9616cd176d28207e3500d095e129049879800595 100644 (file)
@@ -5879,11 +5879,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
        public override void visit_lambda_expression (LambdaExpression lambda) {
                var delegate_type = (DelegateType) lambda.target_type;
-               var d = delegate_type.delegate_symbol;
-
-               lambda.method.set_attribute_bool ("CCode", "array_length", get_ccode_array_length (d));
-               lambda.method.set_attribute_bool ("CCode", "array_null_terminated", get_ccode_array_null_terminated (d));
-               lambda.method.set_attribute_string ("CCode", "array_length_type", get_ccode_array_length_type (d));
 
                lambda.accept_children (this);
 
index 0c55568ac2e9c63e97fae2557064318d1b248715..a5b96c2a60ff999614ead905958c950f29e693cc 100644 (file)
@@ -137,6 +137,14 @@ public class Vala.LambdaExpression : Expression {
                method.used = true;
                method.version.check (source_reference);
 
+               if (return_type is ArrayType) {
+                       method.copy_attribute_bool (cb, "CCode", "array_length");
+                       method.copy_attribute_bool (cb, "CCode", "array_null_terminated");
+                       method.copy_attribute_string (cb, "CCode", "array_length_type");
+               } else if (return_type is DelegateType) {
+                       method.copy_attribute_bool (cb, "CCode", "delegate_target");
+               }
+
                if (!cb.has_target || !context.analyzer.is_in_instance_method ()) {
                        method.binding = MemberBinding.STATIC;
                } else {