modules/ballerina-core/src/main/java/org/ballerinalang/util/semantics/SemanticAnalyzer.java
private static String generateErrorMessage(FunctionInvocationExpr funcIExpr, BLangSymbol functionSymbol,
                                               String packagePath) {
        Function function;
        //in future when native functions support implicit casting invocation, functionSymbol can be either
        //NativeUnitProxy or a Function.
        if (functionSymbol instanceof NativeUnitProxy) {
            NativeUnit nativeUnit = ((NativeUnitProxy) functionSymbol).load();

            if (!(nativeUnit instanceof Function)) {
                BLangExceptionHelper.throwSemanticError(funcIExpr, SemanticErrors.INCOMPATIBLE_TYPES_UNKNOWN_FOUND,
                                                        functionSymbol.getName());
            }
            function = (Function) nativeUnit;
        } else {
            if (!(functionSymbol instanceof Function)) {
                BLangExceptionHelper.throwSemanticError(funcIExpr, SemanticErrors.INCOMPATIBLE_TYPES_UNKNOWN_FOUND,
                                                        functionSymbol.getName());
            }
            function = (Function) functionSymbol;
        }
        //below getName should always return a valid String value, hence ArrayIndexOutOfBoundsException
        // or NullPointerException cannot happen here.
        String funcName = function.getSymbolName().getName().split("\\.")[0];
        String firstPart = (packagePath != null) ? packagePath + ":" + funcName : funcName;

        StringBuilder sBuilder = new StringBuilder(firstPart + "(");
        String prefix = "";
        for (ParameterDef parameterDef : function.getParameterDefs()) {
            sBuilder.append(prefix);
            prefix = ",";
            String pkgPath = parameterDef.getTypeName().getPackagePath();
            if (pkgPath != null) {
                sBuilder.append(pkgPath).append(":");
            }
            sBuilder.append(parameterDef.getTypeName().getName());
        }
        sBuilder.append(")");
        return sBuilder.toString();
    }
/**
     * Helper method to generate error message for each ambiguous function.
     *
     * @param funcIExpr
     * @param functionSymbol
     * @return errorMsg
     */
Helper method to generate error message for each ambiguous function.
@param funcIExpr
@param functionSymbol
@return errorMsg
Helper method to generate error message for each ambiguous function . @param funcIExpr @param functionSymbol @return errorMsg
private static String generateErrorMessage(FunctionInvocationExpr funcIExpr, BLangSymbol functionSymbol,
                                               String packagePath) {
        Function function;
        if (functionSymbol instanceof NativeUnitProxy) {
            NativeUnit nativeUnit = ((NativeUnitProxy) functionSymbol).load();
            if (!(nativeUnit instanceof Function)) {
                BLangExceptionHelper.throwSemanticError(funcIExpr, SemanticErrors.INCOMPATIBLE_TYPES_UNKNOWN_FOUND,
                                                        functionSymbol.getName());
            }
            function = (Function) nativeUnit;
        } else {
            if (!(functionSymbol instanceof Function)) {
                BLangExceptionHelper.throwSemanticError(funcIExpr, SemanticErrors.INCOMPATIBLE_TYPES_UNKNOWN_FOUND,
                                                        functionSymbol.getName());
            }
            function = (Function) functionSymbol;
        }
        String funcName = function.getSymbolName().getName().split("\\.")[0];
        String firstPart = (packagePath != null) ? packagePath + ":" + funcName : funcName;
        StringBuilder sBuilder = new StringBuilder(firstPart + "(");
        String prefix = "";
        for (ParameterDef parameterDef : function.getParameterDefs()) {
            sBuilder.append(prefix);
            prefix = ",";
            String pkgPath = parameterDef.getTypeName().getPackagePath();
            if (pkgPath != null) {
                sBuilder.append(pkgPath).append(":");
            }
            sBuilder.append(parameterDef.getTypeName().getName());
        }
        sBuilder.append(")");
        return sBuilder.toString();
    }
private static String generateErrorMessage ( FunctionInvocationExpr funcIExpr , BLangSymbol functionSymbol , String packagePath ) { Function function ; if ( functionSymbol instanceof NativeUnitProxy ) { NativeUnit nativeUnit = ( ( NativeUnitProxy ) functionSymbol ) . load ( ) ; if ( ! ( nativeUnit instanceof Function ) ) { BLangExceptionHelper . throwSemanticError ( funcIExpr , SemanticErrors . INCOMPATIBLE_TYPES_UNKNOWN_FOUND , functionSymbol . getName ( ) ) ; } function = ( Function ) nativeUnit ; } else { if ( ! ( functionSymbol instanceof Function ) ) { BLangExceptionHelper . throwSemanticError ( funcIExpr , SemanticErrors . INCOMPATIBLE_TYPES_UNKNOWN_FOUND , functionSymbol . getName ( ) ) ; } function = ( Function ) functionSymbol ; } String funcName = function . getSymbolName ( ) . getName ( ) . split ( "\\." ) [ 0 ] ; String firstPart = ( packagePath != null ) ? packagePath + ":" + funcName : funcName ; StringBuilder sBuilder = new StringBuilder ( firstPart + "(" ) ; String prefix = "" ; for ( ParameterDef parameterDef : function . getParameterDefs ( ) ) { sBuilder . append ( prefix ) ; prefix = "," ; String pkgPath = parameterDef . getTypeName ( ) . getPackagePath ( ) ; if ( pkgPath != null ) { sBuilder . append ( pkgPath ) . append ( ":" ) ; } sBuilder . append ( parameterDef . getTypeName ( ) . getName ( ) ) ; } sBuilder . append ( ")" ) ; return sBuilder . toString ( ) ; }
Helper method to generate error message for each ambiguous function.
Helper method to generate error message for each ambiguous function .
//in future when native functions support implicit casting invocation, functionSymbol can be either //NativeUnitProxy or a Function. //below getName should always return a valid String value, hence ArrayIndexOutOfBoundsException // or NullPointerException cannot happen here.