fasterthanlime / shin

:warning: (def shin (dissoc clojurescript :jvm :google_closure)) (deprecated)
MIT License
35 stars 1 forks source link

Fix protocol / type method gen #92

Closed fasterthanlime closed 9 years ago

fasterthanlime commented 9 years ago

They, in fact, don't take this as first argument.

It's just aliased in the body. My bad.

Mainline cljs generated code:

// Compiled by ClojureScript 0.0-2156
goog.provide('wtf_require.client');
goog.require('cljs.core');
wtf_require.client.IRandine = (function() {
    var obj4770 = {};
    return obj4770;
})();
wtf_require.client._dostuff = (function _dostuff(o) {
    if ((function() {
            var and__3391__auto__ = o;
            if (and__3391__auto__) {
                return o.wtf_require$client$IRandine$_dostuff$arity$1;
            } else {
                return and__3391__auto__;
            }
        })()) {
        return o.wtf_require$client$IRandine$_dostuff$arity$1(o);
    } else {
        var x__4030__auto__ = (((o == null)) ? null : o);
        return (function() {
            var or__3403__auto__ = (wtf_require.client._dostuff[goog.typeOf(x__4030__auto__)]);
            if (or__3403__auto__) {
                return or__3403__auto__;
            } else {
                var or__3403__auto____$1 = (wtf_require.client._dostuff["_"]);
                if (or__3403__auto____$1) {
                    return or__3403__auto____$1;
                } else {
                    throw cljs.core.missing_protocol.call(null, "IRandine.-dostuff", o);
                }
            }
        })().call(null, o);
    }
});

/**
 * @constructor
 */
wtf_require.client.Rando = (function() {})
wtf_require.client.Rando.cljs$lang$type = true;
wtf_require.client.Rando.cljs$lang$ctorStr = "wtf_require.client/Rando";
wtf_require.client.Rando.cljs$lang$ctorPrWriter = (function(this__3970__auto__, writer__3971__auto__, opt__3972__auto__) {
    return cljs.core._write.call(null, writer__3971__auto__, "wtf_require.client/Rando");
});
wtf_require.client.Rando.prototype.wtf_require$client$IRandine$ = true;
wtf_require.client.Rando.prototype.wtf_require$client$IRandine$_dostuff$arity$1 = (function(o) {
    var self__ = this;
    var o__$1 = this;
    return cljs.core.prn.call(null, "I'm alive!");
});
wtf_require.client.Rando.prototype.dothings = (function() {
    var self__ = this;
    var o = this;
    return o.wtf_require$client$IRandine$_dostuff$arity$1(null);
});
wtf_require.client.__GT_Rando = (function __GT_Rando() {
    return (new wtf_require.client.Rando());
});

from this clojure code:

(defprotocol IRandine
  (-dostuff [o]))

(deftype Rando []
  Object
  (dothings [o]
    (-dostuff o))

  IRandine
  (-dostuff [o]
    (prn "I'm alive!")))