]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve prototype-string of CallableType
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Mar 2019 17:07:28 +0000 (18:07 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 20 Jan 2021 16:50:47 +0000 (17:50 +0100)
vala/valacallabletype.vala

index 14813ec5bb7778abe393660e8978b36cf61b1017..a3da19518c601452099a416798ebffd537e447eb 100644 (file)
@@ -51,12 +51,23 @@ public abstract class Vala.CallableType : DataType {
        public override string to_prototype_string (string? override_name = null) {
                StringBuilder builder = new StringBuilder ();
 
-               // Append return-type
-               unowned DataType return_type = get_return_type ();
-               if (return_type.is_weak ()) {
-                       builder.append ("unowned ");
+               unowned DelegateType? delegate_type = this as DelegateType;
+               unowned MethodType? method_type = this as MethodType;
+               unowned SignalType? signal_type = this as SignalType;
+
+               if (method_type != null && method_type.method_symbol.coroutine) {
+                       // Only methods can be asynchronous
+                       builder.append ("async ");
+               } else if (delegate_type != null) {
+                       builder.append ("delegate ");
+               } else if (signal_type != null) {
+                       builder.append ("signal ");
+               }
+
+               // Append return-type, but omit return-type for creation methods
+               if (method_type == null || !(method_type.method_symbol is CreationMethod)) {
+                       builder.append (get_return_type ().to_prototype_string ());
                }
-               builder.append (return_type.to_qualified_string ());
 
                // Append name
                builder.append_c (' ');
@@ -67,7 +78,6 @@ public abstract class Vala.CallableType : DataType {
                builder.append_c ('(');
                int i = 1;
                // add sender parameter for internal signal-delegates
-               unowned DelegateType? delegate_type = this as DelegateType;
                if (delegate_type != null) {
                        unowned Delegate delegate_symbol = delegate_type.delegate_symbol;
                        if (delegate_symbol.parent_symbol is Signal && delegate_symbol.sender_type != null) {