]> 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, 17 Mar 2020 14:35:01 +0000 (15:35 +0100)
codegen/valaccodebasemodule.vala
vala/valalambdaexpression.vala

index 6d021ddf373b31ff4804f24e4b7a8db8cbf63c15..e04ad34b55948c456a88e8f3931749d9f644517f 100644 (file)
@@ -5735,11 +5735,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 314bfa7ce90cbc0f13b9b67883bca2032bd55859..7588cea23dc4adcb61efb761fa5417b59f061858 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 {