semantic/unary-unsupported-negation.test \
semantic/yield-call-requires-async-context.test \
semantic/yield-call-requires-async-method.test \
+ semantic/yield-call-requires-async-method-2.test \
semantic/yield-creation-requires-async-context.test \
semantic/yield-creation-requires-async-method.test \
$(NULL)
formal_value_type = ret_type.copy ();
value_type = formal_value_type.get_actual_type (target_object_type, method_type_args, this);
+ if (is_yield_expression) {
+ if (!(mtype is MethodType) || !((MethodType) mtype).method_symbol.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");
+ }
+ }
+
bool may_throw = false;
if (mtype is MethodType) {
var m = ((MethodType) mtype).method_symbol;
- 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");
- }
- }
if (m != null && m.coroutine && !is_yield_expression && ((MemberAccess) call).member_name != "end") {
// .begin call of async method, no error can happen here
} else {