Skip to content

Commit 8d6fdb0

Browse files
louyxstuarthalloway
authored andcommitted
CLJ-1645: protocol class has no source file information
Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent ea7c34b commit 8d6fdb0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/clj/clojure/genclass.clj

+1
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@
669669
iname nil "java/lang/Object"
670670
(when (seq extends)
671671
(into-array (map #(.getInternalName (asm-type %)) extends))))
672+
(when (not= "NO_SOURCE_FILE" *source-path*) (. cv visitSource *source-path* nil))
672673
(add-annotations cv (meta name))
673674
(doseq [[mname pclasses rclass pmetas] methods]
674675
(let [mv (. cv visitMethod (+ Opcodes/ACC_PUBLIC Opcodes/ACC_ABSTRACT)

test/clojure/test_clojure/genclass.clj

+8
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,11 @@
141141
"returnsFloatArray" :floats
142142
"returnsDoubleArray" :doubles
143143
"returnsBooleanArray" :booleans))))))
144+
145+
(deftest gen-interface-source-file
146+
(let [classReader (clojure.asm.ClassReader. "clojure.test_clojure.genclass.examples.ArrayGenInterface")
147+
sourceFile (StringBuilder.)
148+
sourceVisitor (proxy [clojure.asm.ClassVisitor] [clojure.asm.Opcodes/ASM4 nil]
149+
(visitSource [source debug] (.append sourceFile source)))]
150+
(.accept classReader sourceVisitor 0)
151+
(is (= "examples.clj" (str sourceFile)))))

0 commit comments

Comments
 (0)