{"record":{"id":"8770ea23201a6886","repo":"clojure/clojure","slug":"can-t-find-matching-overloaded-method-name-name","errorCode":null,"errorMessage":"Can't find matching overloaded method: ${name.name}","messagePattern":"Can't find matching overloaded method: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/jvm/clojure/lang/Compiler.java","lineNumber":9099,"sourceCode":"\t\t\t\t\tp = Symbol.intern(p.name);\n\t\t\t\tClass pclass = tagClass(tag);\n\t\t\t\tpclasses[i] = pclass;\n\t\t\t\tpsyms[i] = p;\n\t\t\t\t}\n\t\t\tMap matches = findMethodsWithNameAndArity(name.name, parms.count(), overrideables);\n\t\t\tObject mk = msig(name.name, pclasses);\n\t\t\tjava.lang.reflect.Method m = null;\n\t\t\tif(matches.size() > 0)\n\t\t\t\t{\n\t\t\t\t//multiple methods\n\t\t\t\tif(matches.size() > 1)\n\t\t\t\t\t{\n\t\t\t\t\t//must be hinted and match one method\n\t\t\t\t\tif(!hinted)\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"Must hint overloaded method: \" + name.name);\n\t\t\t\t\tm = (java.lang.reflect.Method) matches.get(mk);\n\t\t\t\t\tif(m == null)\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"Can't find matching overloaded method: \" + name.name);\n\t\t\t\t\tif(m.getReturnType() != method.retClass)\n\t\t\t\t\t\tthrow new IllegalArgumentException(\"Mismatched return type: \" + name.name +\n\t\t\t\t\t\t\", expected: \" + m.getReturnType().getName()  + \", had: \" + method.retClass.getName());\n\t\t\t\t\t}\n\t\t\t\telse  //one match\n\t\t\t\t\t{\n\t\t\t\t\t//if hinted, validate match,\n\t\t\t\t\tif(hinted)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tm = (java.lang.reflect.Method) matches.get(mk);\n\t\t\t\t\t\tif(m == null)\n\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"Can't find matching method: \" + name.name +\n\t\t\t\t\t\t\t                                   \", leave off hints for auto match.\");\n\t\t\t\t\t\tif(m.getReturnType() != method.retClass)\n\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"Mismatched return type: \" + name.name +\n\t\t\t\t\t\t\t\", expected: \" + m.getReturnType().getName()  + \", had: \" + method.retClass.getName());\n\t\t\t\t\t\t}\n\t\t\t\t\telse //adopt found method sig","sourceCodeStart":9081,"sourceCodeEnd":9117,"githubUrl":"https://github.com/clojure/clojure/blob/f3b143341d6efc6428b523b2eaa099a6cc99156e/src/jvm/clojure/lang/Compiler.java#L9081-L9117","documentation":"The method name is overloaded and hints were supplied, but the hinted signature (method name + hinted parameter classes) does not match any of the available overloads, so matches.get(msig) returned null. The hints either name the wrong classes or the return-type hint doesn't line up with an actual overload.","triggerScenarios":"(reify Foo (^String bar [this ^Integer x] ...)) where no overload of bar takes Integer at that arity (e.g. only Long or Object exist), so the hinted signature key misses the map of overloads.","commonSituations":"Hinting with boxed types (Integer) where the interface declares primitive (int); hinting String where CharSequence is declared; copying hints from a different overload; hint drift after a library upgrade changed the interface.","solutions":["Check the exact declared parameter types in the interface javadoc and match them byte-for-byte (int vs Integer, CharSequence vs String).","Remove all hints so the compiler auto-matches if there is only one overload of that arity.","Use reflection on the interface class to list overloads: (.getMethods (clojure.lang.RT/classForName \"Foo\"))."],"exampleFix":"// before\n(reify Iface\n  (^String bar [this ^Integer x] (str x)))\n// after\n(reify Iface\n  (bar [this ^int x] (str x)))","handlingStrategy":"validation","validationCode":"(defn declared-params [iface-class method-name arity]\n  (map #(.getParameterTypes %)\n       (filter #(and (= method-name (.getName %))\n                     (= arity (.getParameterCount %)))\n               (.getMethods iface-class))))\n;; hint exactly one of these type lists before implementing","typeGuard":null,"tryCatchPattern":"(try\n  (eval reify-form)\n  (catch IllegalArgumentException e\n    (if (re-find #\"Can't find matching overloaded method\" (.getMessage e))\n      (println \"hinted signature matches no overload — check declared param types\")\n      (throw e))))","preventionTips":["Match hints to declared types exactly: primitives stay primitives, boxed stay boxed.","Inspect (.getMethods iface-class) to see the exact overload signatures.","Drop hints entirely when only one overload exists at that arity."],"tags":["clojure","compiler","type-hints","overloading"],"backgroundTag":"type-mismatch","analyzedSha":"f3b143341d6efc6428b523b2eaa099a6cc99156e","analyzedAt":"2026-09-09T12:04:58.961Z","contentChangedAt":"2026-09-09T12:04:58.961Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}