Exemple #1
0
        public override bool Resolve(BlockContext bc)
        {
            if (!CheckContext(bc, loc))
            {
                return(false);
            }

            if (bc.HasAny(ResolveContext.Options.TryWithCatchScope))
            {
                bc.Report.Error(1626, loc, "Cannot yield a value in the body of a try block with a catch clause");
            }

            if (bc.HasSet(ResolveContext.Options.CatchScope))
            {
                bc.Report.Error(1631, loc, "Cannot yield a value in the body of a catch clause");
            }

            if (!base.Resolve(bc))
            {
                return(false);
            }

            var otype = bc.CurrentIterator.OriginalIteratorType;

            if (expr.Type != otype)
            {
                expr = Convert.ImplicitConversionRequired(bc, expr, otype, loc);
                if (expr == null)
                {
                    return(false);
                }
            }

            return(true);
        }