From: Jürg Billeter Date: Wed, 18 Jul 2012 10:42:23 +0000 (+0200) Subject: Fix async object creation expressions X-Git-Tag: 0.17.4~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67ceef2332eecf30a98ddf3033f179bfbfafa6f6;p=thirdparty%2Fvala.git Fix async object creation expressions Fixes bug 680063. --- diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala index d96fb6503..400bc4c32 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 arg_it = args.iterator (); foreach (Parameter param in m.get_parameters ()) {