private void SetScopeSource(Symbol classSymbol)
 {
     Current = classSymbol;
 }
        private void ValidateReturnStatementType(MethodDeclr ast, Symbol symbol)
        {
            if (!ResolvingTypes)
            {
                return;
            }

            IType returnStatementType;

            // no return found
            if (ast.ReturnAst == null)
            {
                returnStatementType = new BuiltInType(ExpressionTypes.Void);
            }
            else
            {
                returnStatementType = ast.ReturnAst.AstSymbolType;
            }

            var delcaredSymbol = ScopeUtil.CreateSymbolType(ast.MethodReturnType);

            // if its inferred, just use whatever the return statement i
            if (delcaredSymbol.ExpressionType == ExpressionTypes.Inferred)
            {
                return;
            }

            if (!TokenUtil.EqualOrPromotable(returnStatementType.ExpressionType, delcaredSymbol.ExpressionType))
            {
                throw new InvalidSyntax(String.Format("Return type {0} for function {1} is not of the same type of declared method (type {2})",
                    returnStatementType.ExpressionType, symbol.Name, delcaredSymbol.ExpressionType));
            }
        }
        private void DefineToScope(Ast ast, Symbol symbol)
        {
            if (ast.CurrentScope != null && ast.CurrentScope.Symbols.ContainsKey(symbol.Name))
            {
                Symbol old = ast.CurrentScope.Resolve(symbol.Name);
                if (old.Type == null)
                {
                    ast.CurrentScope.Define(symbol);
                }
            }

            Current.Define(symbol);
        }