Commit 8b27678d authored by Rico Tzschichholz's avatar Rico Tzschichholz

vala: Don't tweak closure on static lambdas

Regression of 92ba4e17

Fixes #740
parent 345f6251
......@@ -239,6 +239,7 @@ TESTS = \
delegates/fields.vala \
delegates/fields-no-target.vala \
delegates/instance-method-to-no-target.test \
delegates/lambda-mixed-instance-static.vala \
delegates/lambda-shared-closure.vala \
delegates/reference_transfer.vala \
delegates/wrapper.vala \
......
[CCode (has_target = false)]
delegate int FooFunc (int i);
delegate int BarFunc (int i);
void func (FooFunc f, BarFunc b) {
assert (f (42) == 42);
assert (b (23) == 4711);
}
void main () {
int global = 4711;
func (
(i) => { assert (i == 42); return i; },
(i) => { assert (i == 23); return global; }
);
}
......@@ -488,8 +488,9 @@ public class Vala.MethodCall : Expression {
// TODO https://gitlab.gnome.org/GNOME/vala/issues/59
if (force_lambda_method_closure) {
foreach (Expression arg in get_argument_list ()) {
if (arg is LambdaExpression) {
((LambdaExpression) arg).method.closure = true;
unowned LambdaExpression? lambda = arg as LambdaExpression;
if (lambda != null && lambda.method.binding != MemberBinding.STATIC) {
lambda.method.closure = true;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment