Permalink
Browse files

CLJS-617: type-hinted ^not-native calls, double expr evaluation

We just needed to use this-as consistently in protocol fn
implementations. The compiler when emitting a direct proto invoke skips
the first arg and sets it to null.
  • Loading branch information...
1 parent e34fddf commit 72f2bd7bd71f7917109a07172dc39c57a5794069 @swannodette swannodette committed Oct 12, 2013
Showing with 7 additions and 5 deletions.
  1. +1 −1 src/clj/cljs/compiler.clj
  2. +6 −4 src/clj/cljs/core.clj
View
2 src/clj/cljs/compiler.clj
@@ -698,7 +698,7 @@
proto?
(let [pimpl (str (munge (protocol-prefix protocol))
(munge (name (:name info))) "$arity$" (count args))]
- (emits (first args) "." pimpl "(" (comma-sep args) ")"))
+ (emits (first args) "." pimpl "(" (comma-sep (cons "null" (rest args))) ")"))
keyword?
(emits f ".call(" (comma-sep (cons "null" args)) ")")
View
10 src/clj/cljs/core.clj
@@ -630,13 +630,15 @@
`(set! ~(prototype-prefix 'apply)
~(with-meta
`(fn ~[this-sym argsym]
- (.apply (.-call ~this-sym) ~this-sym
- (.concat (array ~this-sym) (aclone ~argsym))))
+ (this-as ~this-sym
+ (.apply (.-call ~this-sym) ~this-sym
+ (.concat (array ~this-sym) (aclone ~argsym)))))
(meta form)))])
(let [pf (core/str pprefix f)
adapt-params (fn [[[targ & args :as sig] & body]]
- (cons (vec (cons (vary-meta targ assoc :tag t) args))
- body))]
+ `(~(vec (cons (vary-meta targ assoc :tag t) args))
+ (this-as ~targ
+ ~@body)))]
(if (vector? (first meths))
[`(set! ~(prototype-prefix (core/str pf "$arity$" (count (first meths)))) ~(with-meta `(fn ~@(adapt-params meths)) (meta form)))]
(map (fn [[sig & body :as meth]]

0 comments on commit 72f2bd7

Please sign in to comment.