Exemplo n.º 1
0
        public override void OnReturnStatement(ReturnStatement node)
        {
            var declaringMethod = node.GetAncestor <Method>();

            if (declaringMethod.IsConstructor())
            {
                return;
            }

            if (NoReturnValueWasSpecified(node))
            {
                base.OnReturnStatement(node);
                return;
            }

            var declaredReturnType = (IType)declaringMethod.ReturnType.Entity;

            if (declaredReturnType.IsEnum ^ node.Expression.ExpressionType.IsEnum)
            {
                node.Replace(node.Expression, CodeBuilder.CreateCast(declaredReturnType, node.Expression));
            }

            base.OnReturnStatement(node);
        }