`proxy` is broken
Closed this issue · 2 comments
(read (proxy [clojure.lang.PushbackTextReader] [(System.IO.StringReader. "100")]))
ends up in:
System.MissingMethodException: Method 'System.String.replace' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at clojure.lang.Reflector.CallInstanceMethod(String methodName, Object target, Object[] args) in C:\Temp\clojure-clr\Clojure\Clojure\Runtime\Reflector.cs:line 157
at clojure/core$fn__8346$proxy_name__8348.__invokeHelper_2(clojure/core$fn__8346$proxy_name__8348_base this, Object super, Object interfaces)
at clojure/core$fn__8370$get_proxy_class__8372.__invokeHelper_0v(clojure/core$fn__8370$get_proxy_class__8372_base this, Object bases)
at clojure.lang.RestFn.applyTo(ISeq args) in C:\Temp\clojure-clr\Clojure\Clojure\Lib\RestFn.cs:line 177
at clojure/core$fn__4990$apply__4992.__invokeHelper_2(clojure/core$fn__4990$apply__4992_base this, Object f, Object args)
at clojure/core$fn__8403$proxy__8405.__invokeHelper_2v(clojure/core$fn__8403$proxy__8405_base this, Object class_and_interfaces, Object args, Object fs)
at clojure.lang.RestFn.invoke(Object arg1, Object arg2) in C:\Temp\clojure-clr\Clojure\Clojure\Lib\RestFn.cs:line 469
at clojure.lang.Var.invoke(Object arg1, Object arg2) in C:\Temp\clojure-clr\Clojure\Clojure\Lib\Var.cs:line 607
at clojure.lang.AFn.ApplyToHelper(IFn ifn, ISeq arglist) in C:\Temp\clojure-clr\Clojure\Clojure\Lib\AFn.cs:line 223
at clojure.lang.Var.applyTo(ISeq arglist) in C:\Temp\clojure-clr\Clojure\Clojure\Lib\Var.cs:line 735
at clojure.lang.Compiler.MacroexpandSeq1(ISeq form) in C:\Temp\clojure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 497
at clojure.lang.Compiler.AnalyzeSeq(ISeq form, String name, Boolean isRecurContext) in C:\Temp\clojure-clr\Clojure\Clojure\CljCompiler\Compiler.cs:line 432 (NO_SOURCE_FILE:230)
(on the JVM, (read (proxy [java.io.PushbackReader] [(java.io.StringReader. "100")]))
works fine).
This actually happened when trying to convert clojure.contrib.repl-utils/get-source to use the CLR, so the proxy had redefined methods, unlike the simplified example here.
On closer examination, core_proxy.clj/proxy-name seems to have more 'lower case first' method calls. Fixing them fixes this issue.
diff --git a/Clojure/Clojure.Source/clojure/core_proxy.clj b/Clojure/Clojure.Source/clojure/core_proxy.clj
index 424a0b6..fca0814 100644
--- a/Clojure/Clojure.Source/clojure/core_proxy.clj
+++ b/Clojure/Clojure.Source/clojure/core_proxy.clj
@@ -43,12 +43,12 @@
(defn proxy-name
{:tag String}
[#^Type super interfaces] ;;; Class
- (let [inames (into (sorted-set) (map #(.getName #^Type %) interfaces))] ;;; #^Class
- (apply str (.replace (str *ns*) \- \_) ".proxy"
+ (let [inames (into (sorted-set) (map #(.Name #^Type %) interfaces))] ;;; #^Class
+ (apply str (.Replace (str *ns*) \- \_) ".proxy"
(interleave (repeat "$")
(concat
[(.FullName super)] ;;; .getName
- (map #(subs % (inc (.lastIndexOf #^String % "."))) inames)
+ (map #(subs % (inc (.LastIndexOf #^String % "."))) inames)
[(.ToString (hash inames) "X")]))))) ;;;[(Integer/toHexString (hash inames))])))))
(defn- generate-proxy [#^Type super interfaces] ;;; Class