Skip to content

Commit

Permalink
Fix CLJ-1330: make top-level named functions classnames don't clash w…
Browse files Browse the repository at this point in the history
…ith def'ed function classnames

Signed-off-by: Stuart Halloway <stu@cognitect.com>
  • Loading branch information
Bronsa authored and stuarthalloway committed Oct 7, 2014
1 parent 8af7e9a commit f149260
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/jvm/clojure/lang/Compiler.java
Expand Up @@ -3840,17 +3840,28 @@ static Expr parse(C context, ISeq form, String name) {
// fn.superName = (String) RT.get(RT.meta(form.first()), Keyword.intern(null, "super-name"));
}
//fn.thisName = name;
String basename = enclosingMethod != null ?
(enclosingMethod.objx.name + "$")
: //"clojure.fns." +
(munge(currentNS().name.name) + "$");
if(RT.second(form) instanceof Symbol)
name = ((Symbol) RT.second(form)).name;
String simpleName = name != null ?
(munge(name).replace(".", "_DOT_")
+ (enclosingMethod != null ? "__" + RT.nextID() : ""))
: ("fn"
+ "__" + RT.nextID());

String basename = (enclosingMethod != null ?
enclosingMethod.objx.name
: (munge(currentNS().name.name))) + "$";

Symbol nm = null;

if(RT.second(form) instanceof Symbol) {
nm = (Symbol) RT.second(form);
if (name == null)
name = nm.name + "__" + RT.nextID();
else
name += "__" + nm.name + "__" + RT.nextID();
} else {
if(name == null)
name = "fn__" + RT.nextID();
else if (enclosingMethod != null)
name += "__" + RT.nextID();
}

String simpleName = munge(name).replace(".", "_DOT_");

fn.name = basename + simpleName;
fn.internalName = fn.name.replace('.', '/');
fn.objtype = Type.getObjectType(fn.internalName);
Expand All @@ -3869,9 +3880,8 @@ VAR_CALLSITES, emptyVarCallSites(),
));

//arglist might be preceded by symbol naming this fn
if(RT.second(form) instanceof Symbol)
if(nm != null)
{
Symbol nm = (Symbol) RT.second(form);
fn.thisName = nm.name;
fn.isStatic = false; //RT.booleanCast(RT.get(nm.meta(), staticKey));
form = RT.cons(FN, RT.next(RT.next(form)));
Expand Down

0 comments on commit f149260

Please sign in to comment.