protected override Expression DoResolve(ResolveContext rc) { if (rc.HasSet(ResolveContext.Options.LockScope)) { rc.Report.Error(1996, loc, "The `await' operator cannot be used in the body of a lock statement"); } if (rc.IsUnsafe) { rc.Report.Error(4004, loc, "The `await' operator cannot be used in an unsafe context"); } var bc = (BlockContext)rc; stmt = new AwaitStatement(expr, loc); if (!stmt.Resolve(bc)) { return(null); } if (rc.HasSet(ResolveContext.Options.FinallyScope) && rc.CurrentAnonymousMethod != null) { var ats = (AsyncTaskStorey)rc.CurrentAnonymousMethod.Storey; ats.HasAwaitInsideFinally = true; } type = stmt.ResultType; eclass = ExprClass.Variable; return(this); }
protected override Expression DoResolve(ResolveContext rc) { if (rc.HasSet(ResolveContext.Options.LockScope)) { rc.Report.Error(1996, loc, "The `await' operator cannot be used in the body of a lock statement"); } if (rc.IsUnsafe) { rc.Report.Error(4004, loc, "The `await' operator cannot be used in an unsafe context"); } var bc = (BlockContext)rc; stmt = new AwaitStatement(expr, loc); if (!stmt.Resolve(bc)) { return(null); } type = stmt.ResultType; eclass = ExprClass.Variable; return(this); }
protected override Expression DoResolve(ResolveContext rc) { if (rc.HasSet(ResolveContext.Options.FinallyScope)) { rc.Report.Error(1984, loc, "The `await' operator cannot be used in the body of a finally clause"); } if (rc.HasSet(ResolveContext.Options.CatchScope)) { rc.Report.Error(1985, loc, "The `await' operator cannot be used in the body of a catch clause"); } if (rc.HasSet(ResolveContext.Options.LockScope)) { rc.Report.Error(1996, loc, "The `await' operator cannot be used in the body of a lock statement"); } if (rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { rc.Report.Error(1989, loc, "An expression tree cannot contain an await operator"); return(null); } if (rc.IsUnsafe) { // TODO: New error code rc.Report.Error(-1900, loc, "The `await' operator cannot be used in an unsafe context"); } var bc = (BlockContext)rc; if (!bc.CurrentBlock.ParametersBlock.IsAsync) { // TODO: Should check for existence of await type but // what to do with it } stmt = new AwaitStatement(expr, loc); if (!stmt.Resolve(bc)) { return(null); } type = stmt.ResultType; eclass = ExprClass.Variable; return(this); }