]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix async object creation expressions
authorJürg Billeter <j@bitron.ch>
Wed, 18 Jul 2012 10:42:23 +0000 (12:42 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 18 Jul 2012 10:43:48 +0000 (12:43 +0200)
Fixes bug 680063.

vala/valaobjectcreationexpression.vala

index d96fb650356e924ea1a5f2da6f88322bda97ed91..400bc4c323f05e3990c2966df5b4deea6a97fcca 100644 (file)
@@ -1,6 +1,6 @@
 /* valaobjectcreationexpression.vala
  *
- * Copyright (C) 2006-2010  Jürg Billeter
+ * Copyright (C) 2006-2012  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -325,6 +325,18 @@ public class Vala.ObjectCreationExpression : Expression {
                if (symbol_reference is Method) {
                        var m = (Method) symbol_reference;
 
+                       if (is_yield_expression) {
+                               if (!m.coroutine) {
+                                       error = true;
+                                       Report.error (source_reference, "yield expression requires async method");
+                               }
+                               if (context.analyzer.current_method == null || !context.analyzer.current_method.coroutine) {
+                                       error = true;
+                                       Report.error (source_reference, "yield expression not available outside async method");
+                               }
+                               context.analyzer.current_method.yield_count++;
+                       }
+
                        var args = get_argument_list ();
                        Iterator<Expression> arg_it = args.iterator ();
                        foreach (Parameter param in m.get_parameters ()) {