@CheckForNull TypeSubstitution getTypeSubstitution(JavaSymbol.MethodJavaSymbol method, JavaType site, List<JavaType> typeParams, List<JavaType> argTypes) { List<JavaType> formals = ((MethodJavaType) method.type).argTypes; TypeSubstitution substitution = new TypeSubstitution(); if (method.isParametrized() || constructParametrizedTypeWithoutSubstitution(method, site)) { if (!typeParams.isEmpty()) { substitution = getSubstitutionFromTypeParams(method.typeVariableTypes, typeParams); } else if (formals.isEmpty()) { // substitution can not be inferred, as it is not based on arguments, method call is still valid return substitution; } else { formals = applySiteSubstitutionToFormalParameters(formals, site); substitution = typeInferenceSolver.inferTypeSubstitution(method, formals, argTypes); } if (!isValidSubstitution(substitution, site)) { // check for valid substitution in supertypes, null if no valid substitution is found return getTypeSubstitutionFromSuperTypes(method, site, typeParams, argTypes); } } return substitution; }
@CheckForNull TypeSubstitution getTypeSubstitution(JavaSymbol.MethodJavaSymbol method, JavaType site, List<JavaType> typeParams, List<JavaType> argTypes) { List<JavaType> formals = ((MethodJavaType) method.type).argTypes; TypeSubstitution substitution = new TypeSubstitution(); if (method.isParametrized() || constructParametrizedTypeWithoutSubstitution(method, site)) { if (!typeParams.isEmpty()) { substitution = getSubstitutionFromTypeParams(method.typeVariableTypes, typeParams); } else if (formals.isEmpty()) { // substitution can not be inferred, as it is not based on arguments, method call is still valid return substitution; } else { formals = applySiteSubstitutionToFormalParameters(formals, site); substitution = typeInferenceSolver.inferTypeSubstitution(method, formals, argTypes); } if (!isValidSubstitution(substitution, site)) { // check for valid substitution in supertypes, null if no valid substitution is found return getTypeSubstitutionFromSuperTypes(method, site, typeParams, argTypes); } } return substitution; }