コード例 #1
0
        // Check if the given symbol can be accessed with the given arity. If OK, return false.
        // If not OK, return true and return a diagnosticinfo. Note that methods with type arguments
        // can be accesses with arity zero due to type inference (but non types).
        private bool WrongArity(Symbol symbol, int arity, out DiagnosticInfo diagInfo)
        {
            switch (symbol.Kind)
            {
            case SymbolKind.NamedType:
                NamedTypeSymbol namedType = (NamedTypeSymbol)symbol;
                if (namedType.Arity != arity)
                {
                    diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_BadArity, namedType.GetFullName(), namedType.Arity);
                    return(true);
                }
                break;

            case SymbolKind.Method:
                if (arity != 0)
                {
                    MethodSymbol method = (MethodSymbol)symbol;
                    if (method.Arity != arity)
                    {
                        diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_HasNoTypeVars, method.GetFullName());
                        return(true);
                    }
                }
                break;

            default:
                if (arity != 0)
                {
                    diagInfo = new CSDiagnosticInfo(ErrorCode.ERR_TypeArgsNotAllowed, symbol.GetFullName());
                    return(true);
                }
                break;
            }

            diagInfo = null;
            return(false);
        }