Skip to content

Commit 32bbd0f

Browse files
committed
- experiment w/ missing @OverRide docstring on toString impls
1 parent 4d13556 commit 32bbd0f

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3393,7 +3393,7 @@ reduces them without incurring seq initialization"
33933393
nsc)))
33943394
:default (garray/defaultCompare (.-name a) (.-name b))))
33953395

3396-
(deftype Keyword [ns name fqn ^:mutable _hash]
3396+
(deftype Keyword [ns name ^string fqn ^:mutable _hash]
33973397
Object
33983398
(toString [_] (str ":" fqn))
33993399
(equiv [this other]

src/main/clojure/cljs/core.cljc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,18 @@
936936
(core/list 'js* "debugger")
937937
nil))
938938

939+
(core/defmacro js-doc
940+
[comment]
941+
(core/let [[x & ys] (string/split comment #"\n")]
942+
(core/list 'js*
943+
(core/str
944+
"/**\n"
945+
(core/str " * " x "\n")
946+
(core/->> ys
947+
(map #(core/str " * " (string/replace % #"^ " "") "\n"))
948+
(reduce core/str ""))
949+
" */"))))
950+
939951
(core/defmacro js-comment
940952
"Emit a top-level JavaScript multi-line comment. New lines will create a
941953
new comment line. Comment block will be preceded and followed by a newline"
@@ -1485,12 +1497,16 @@
14851497
~@body))))
14861498

14871499
(core/defn- add-obj-methods [type type-sym sigs]
1488-
(map (core/fn [[f & meths :as form]]
1489-
(core/let [[f meths] (if (vector? (first meths))
1490-
[f [(rest form)]]
1491-
[f meths])]
1492-
`(set! ~(extend-prefix type-sym f)
1493-
~(with-meta `(fn ~@(map #(adapt-obj-params type %) meths)) (meta form)))))
1500+
(mapcat
1501+
(core/fn [[f & meths :as form]]
1502+
(core/let [[f meths] (if (vector? (first meths))
1503+
[f [(rest form)]]
1504+
[f meths])
1505+
exp [`(set! ~(extend-prefix type-sym f)
1506+
~(with-meta `(fn ~@(map #(adapt-obj-params type %) meths)) (meta form)))]]
1507+
(if (= f 'toString)
1508+
(into [`(js-doc "@return {string}\n@override")] exp)
1509+
exp)))
14941510
sigs))
14951511

14961512
(core/defn- ifn-invoke-methods [type type-sym [f & meths :as form]]

0 commit comments

Comments
 (0)