diff options
Diffstat (limited to 'vala/valadelegate.vala')
-rw-r--r-- | vala/valadelegate.vala | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala index 813a73479..200b2dbc2 100644 --- a/vala/valadelegate.vala +++ b/vala/valadelegate.vala @@ -165,27 +165,33 @@ public class Vala.Delegate : TypeSymbol, Callable { bool first = true; foreach (Parameter param in parameters) { + DataType method_param_type; /* use first callback parameter as instance parameter if * an instance method is being compared to a static * callback */ if (first && m.binding == MemberBinding.INSTANCE && !has_target) { first = false; - continue; - } - - /* method is allowed to accept less arguments */ - if (!method_params_it.next ()) { - break; + method_param_type = SemanticAnalyzer.get_data_type_for_symbol (m.parent_symbol); + } else { + /* method is allowed to accept less arguments */ + if (!method_params_it.next ()) { + break; + } + method_param_type = method_params_it.get ().variable_type; } // method is allowed to accept arguments of looser types (weaker precondition) - var method_param = method_params_it.get (); - if (!param.variable_type.get_actual_type (dt, null, this).stricter (method_param.variable_type)) { + if (!param.variable_type.get_actual_type (dt, null, this).stricter (method_param_type)) { return false; } } + // delegate without target for instance method or closure + if (first && m.binding == MemberBinding.INSTANCE && !has_target) { + return false; + } + /* method may not expect more arguments */ if (method_params_it.next ()) { return false; |