[vala/0.48] vala: Improve prototype-string of CallableType



commit 645ab065d2cee0a6ba456ba72f9cd6cf9b83f674
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Mar 14 18:07:28 2019 +0100

    vala: Improve prototype-string of CallableType

 vala/valacallabletype.vala | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/vala/valacallabletype.vala b/vala/valacallabletype.vala
index 14813ec5b..a3da19518 100644
--- a/vala/valacallabletype.vala
+++ b/vala/valacallabletype.vala
@@ -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) {


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