Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove `extend-type function` to `IWithMeta`, move logic into `with-m…

…eta`
  • Loading branch information...
commit e0f6fd5d00e5de3d8c2544acdc520807bdb0857a 1 parent f5ac74e
@swannodette swannodette authored
Showing with 12 additions and 13 deletions.
  1. +12 −13 src/cljs/cljs/core.cljs
View
25 src/cljs/cljs/core.cljs
@@ -517,19 +517,8 @@
(extend-type function
Fn
-
IMeta
- (-meta [_] nil)
-
- IWithMeta
- (-with-meta [f meta]
- (with-meta
- (reify
- Fn
- IFn
- (-invoke [_ & args]
- (apply f args)))
- meta)))
+ (-meta [_] nil))
(extend-type default
IHash
@@ -912,11 +901,21 @@ reduces them without incurring seq initialization"
(recur ret (first ks) (next ks))
ret))))
+(declare fn?)
+
(defn with-meta
"Returns an object of the same type and value as obj, with
map m as its metadata."
[o meta]
- (-with-meta o meta))
+ (if (and (fn? o) (not (satisfies? IWithMeta o)))
+ (with-meta
+ (reify
+ Fn
+ IFn
+ (-invoke [_ & args]
+ (apply o args)))
+ meta)
+ (-with-meta o meta)))
(defn meta
"Returns the metadata of obj, returns nil if there is no metadata."
Please sign in to comment.
Something went wrong with that request. Please try again.