From: Jürg Billeter Date: Sun, 4 Mar 2007 18:16:16 +0000 (+0000) Subject: support lambda expressions in constructors remove extra printf argument X-Git-Tag: VALA_0_0_7~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b90b30377e0bd076964569554ab2c7b315717e64;p=platform%2Fupstream%2Fvala.git support lambda expressions in constructors remove extra printf argument 2007-03-04 Jürg Billeter * vala/valasemanticanalyzer.vala: support lambda expressions in constructors * tests/test-029.vala: remove extra printf argument svn path=/trunk/; revision=217 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index 1a089b7..1b9a08b 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,9 @@ +2007-03-04 Jürg Billeter + + * vala/valasemanticanalyzer.vala: support lambda expressions in + constructors + * tests/test-029.vala: remove extra printf argument + 2007-03-04 Raffaele Sandrini * vala/valasemanticanalyzer.vala, vala/parser.y, diff --git a/vala/tests/test-029.vala b/vala/tests/test-029.vala index e913e82..62caf66 100644 --- a/vala/tests/test-029.vala +++ b/vala/tests/test-029.vala @@ -17,7 +17,7 @@ class Maman.Foo { stdout.printf (" %d", foo.p2); stdout.printf (" %d", foo.p1); - stdout.printf (" 5\n", foo.p2); + stdout.printf (" 5\n"); return 0; } diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index 956d6f2..0fc5c93 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -1558,6 +1558,17 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } return null; } + + private bool is_in_constructor () { + var sym = current_symbol; + while (sym != null) { + if (sym.node is Constructor) { + return true; + } + sym = sym.parent_symbol; + } + return false; + } public override void visit_begin_lambda_expression (LambdaExpression! l) { if (l.expected_type == null || !(l.expected_type.data_type is Callback)) { @@ -1566,11 +1577,17 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } + bool in_instance_method = false; var current_method = find_current_method (); + if (current_method != null) { + in_instance_method = current_method.instance; + } else { + in_instance_method = is_in_constructor (); + } var cb = (Callback) l.expected_type.data_type; l.method = new Method (get_lambda_name (), cb.return_type); - l.method.instance = cb.instance && current_method.instance; + l.method.instance = cb.instance && in_instance_method; l.method.symbol = new Symbol (l.method); l.method.symbol.parent_symbol = current_symbol;