From: Rico Tzschichholz Date: Thu, 14 Mar 2019 17:07:28 +0000 (+0100) Subject: vala: Improve prototype-string of CallableType X-Git-Tag: 0.51.1~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c417d8babc9728306051aa065e601208f63a03c1;p=thirdparty%2Fvala.git vala: Improve prototype-string of CallableType --- 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) {