public boolean invocationApplicabilityInference ( MethodCallExpr methodCallExpr , ResolvedMethodDeclaration methodDeclaration ) { if ( ! methodCallExpr . getNameAsString ( ) . equals ( methodDeclaration . getName ( ) ) ) { throw new IllegalArgumentException ( ) ; } Optional < InstantiationSet > partial = instantiationInference ( methodCallExpr , methodDeclaration ) ; if ( ! partial . isPresent ( ) ) { return false ; } int nActualParams = methodCallExpr . getArguments ( ) . size ( ) ; int nFormalParams = methodDeclaration . getNumberOfParams ( ) ; if ( nActualParams != nFormalParams ) { if ( methodDeclaration . hasVariadicParameter ( ) ) { if ( nActualParams < ( nFormalParams - 1 ) ) { return false ; } } else { return false ; } } //MethodUsage methodUsage = instantiationSetToMethodUsage(methodDeclaration, partial.get()); // for (int i=0;i<nActualParams;i++) { // int formalIndex = i >= nFormalParams ? nFormalParams - 1 : i; // Type formalType = methodDeclaration.getParam(formalIndex).getType(); // Type actualType = JavaParserFacade.get(typeSolver).getType(methodCallExpr.getArgument(i)); // //if (!formalType.isAssignableBy(actualType)) { // // return false; // //} // } return true ; }
Determine whether a potentially applicable generic method m is applicable for a method invocation that provides no explicit type arguments .