MCPcopy Index your code
hub / github.com/clojure/clojure / getMatchingParams

Method getMatchingParams

src/jvm/clojure/lang/Compiler.java:3014–3068  ·  view source on GitHub ↗
(String methodName, ArrayList<Class[]> paramlists, IPersistentVector argexprs,
                             List<Class> rets)

Source from the content-addressed store, hash-verified

3012}
3013
3014static int getMatchingParams(String methodName, ArrayList<Class[]> paramlists, IPersistentVector argexprs,
3015 List<Class> rets)
3016 {
3017 //presumes matching lengths
3018 int matchIdx = -1;
3019 boolean tied = false;
3020 boolean foundExact = false;
3021 for(int i = 0; i < paramlists.size(); i++)
3022 {
3023 boolean match = true;
3024 ISeq aseq = argexprs.seq();
3025 int exact = 0;
3026 for(int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.next())
3027 {
3028 Expr arg = (Expr) aseq.first();
3029 Class aclass = arg.hasJavaClass() ? arg.getJavaClass() : Object.class;
3030 Class pclass = paramlists.get(i)[p];
3031 if(arg.hasJavaClass() && aclass == pclass)
3032 exact++;
3033 else
3034 match = Reflector.paramArgTypeMatch(pclass, aclass);
3035 }
3036 if(exact == argexprs.count())
3037 {
3038 if(!foundExact || matchIdx == -1 || rets.get(matchIdx).isAssignableFrom(rets.get(i)))
3039 matchIdx = i;
3040 tied = false;
3041 foundExact = true;
3042 }
3043 else if(match && !foundExact)
3044 {
3045 if(matchIdx == -1)
3046 matchIdx = i;
3047 else
3048 {
3049 if(subsumes(paramlists.get(i), paramlists.get(matchIdx)))
3050 {
3051 matchIdx = i;
3052 tied = false;
3053 }
3054 else if(Arrays.equals(paramlists.get(matchIdx), paramlists.get(i)))
3055 {
3056 if(rets.get(matchIdx).isAssignableFrom(rets.get(i)))
3057 matchIdx = i;
3058 }
3059 else if(!(subsumes(paramlists.get(matchIdx), paramlists.get(i))))
3060 tied = true;
3061 }
3062 }
3063 }
3064 if(tied)
3065 throw new IllegalArgumentException("More than one matching method found: " + methodName);
3066
3067 return matchIdx;
3068}
3069
3070public static class NewExpr implements Expr{
3071 public final IPersistentVector args;

Callers 3

InstanceMethodExprMethod · 0.80
StaticMethodExprMethod · 0.80
NewExprMethod · 0.80

Calls 11

nextMethod · 0.95
firstMethod · 0.95
hasJavaClassMethod · 0.95
getJavaClassMethod · 0.95
paramArgTypeMatchMethod · 0.95
subsumesMethod · 0.95
seqMethod · 0.65
countMethod · 0.65
getMethod · 0.65
sizeMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected