This currently requires to consider compatible delegates as equal.
delegates/error-pos.vala \
delegates/fields.vala \
delegates/fields-no-target.vala \
+ delegates/incompatible.test \
+ delegates/incompatible-target.test \
delegates/instance-method-to-no-target.test \
delegates/lambda-mixed-instance-static.vala \
delegates/lambda-shared-closure.vala \
--- /dev/null
+Invalid Code
+
+delegate void Func ();
+[CCode (has_target = false)]
+delegate void IncompatibleFunc ();
+
+interface Foo : Object {
+ public abstract void foo (Func? func);
+}
+
+class Bar : Object, Foo {
+ public void foo (IncompatibleFunc? func) {
+ }
+}
+
+void main () {
+}
--- /dev/null
+Invalid Code
+
+delegate void Func ();
+delegate void IncompatibleFunc (string s);
+
+interface Foo : Object {
+ public abstract void foo (Func? func);
+}
+
+class Bar : Object, Foo {
+ public void foo (IncompatibleFunc? func) {
+ }
+}
+
+void main () {
+}
return result;
}
+ public override bool equals (DataType type2) {
+ return compatible (type2);
+ }
+
public override bool is_accessible (Symbol sym) {
return delegate_symbol.is_accessible (sym);
}
return true;
}
+ if (delegate_symbol.has_target != dt_target.delegate_symbol.has_target) {
+ return false;
+ }
+
// target-delegate is allowed to ensure stricter return type (stronger postcondition)
if (!get_return_type ().stricter (dt_target.get_return_type ().get_actual_type (dt_target, null, this))) {
return false;
}
foreach (Parameter param in dt_target.get_parameters ()) {
- /* target-delegate is allowed to accept less arguments */
if (!params_it.next ()) {
- break;
+ return false;
}
// target-delegate is allowed to accept arguments of looser types (weaker precondition)