[vala] Fix async object creation expressions



commit 67ceef2332eecf30a98ddf3033f179bfbfafa6f6
Author: JÃrg Billeter <j bitron ch>
Date:   Wed Jul 18 12:42:23 2012 +0200

    Fix async object creation expressions
    
    Fixes bug 680063.

 vala/valaobjectcreationexpression.vala |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index d96fb65..400bc4c 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -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 ()) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]