Skip to content

Commit f149260

Browse files
bronsastuarthalloway
authored andcommitted
Fix CLJ-1330: make top-level named functions classnames don't clash with def'ed function classnames
Signed-off-by: Stuart Halloway <stu@cognitect.com>
1 parent 8af7e9a commit f149260

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

src/jvm/clojure/lang/Compiler.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,17 +3840,28 @@ static Expr parse(C context, ISeq form, String name) {
38403840
// fn.superName = (String) RT.get(RT.meta(form.first()), Keyword.intern(null, "super-name"));
38413841
}
38423842
//fn.thisName = name;
3843-
String basename = enclosingMethod != null ?
3844-
(enclosingMethod.objx.name + "$")
3845-
: //"clojure.fns." +
3846-
(munge(currentNS().name.name) + "$");
3847-
if(RT.second(form) instanceof Symbol)
3848-
name = ((Symbol) RT.second(form)).name;
3849-
String simpleName = name != null ?
3850-
(munge(name).replace(".", "_DOT_")
3851-
+ (enclosingMethod != null ? "__" + RT.nextID() : ""))
3852-
: ("fn"
3853-
+ "__" + RT.nextID());
3843+
3844+
String basename = (enclosingMethod != null ?
3845+
enclosingMethod.objx.name
3846+
: (munge(currentNS().name.name))) + "$";
3847+
3848+
Symbol nm = null;
3849+
3850+
if(RT.second(form) instanceof Symbol) {
3851+
nm = (Symbol) RT.second(form);
3852+
if (name == null)
3853+
name = nm.name + "__" + RT.nextID();
3854+
else
3855+
name += "__" + nm.name + "__" + RT.nextID();
3856+
} else {
3857+
if(name == null)
3858+
name = "fn__" + RT.nextID();
3859+
else if (enclosingMethod != null)
3860+
name += "__" + RT.nextID();
3861+
}
3862+
3863+
String simpleName = munge(name).replace(".", "_DOT_");
3864+
38543865
fn.name = basename + simpleName;
38553866
fn.internalName = fn.name.replace('.', '/');
38563867
fn.objtype = Type.getObjectType(fn.internalName);
@@ -3869,9 +3880,8 @@ VAR_CALLSITES, emptyVarCallSites(),
38693880
));
38703881

38713882
//arglist might be preceded by symbol naming this fn
3872-
if(RT.second(form) instanceof Symbol)
3883+
if(nm != null)
38733884
{
3874-
Symbol nm = (Symbol) RT.second(form);
38753885
fn.thisName = nm.name;
38763886
fn.isStatic = false; //RT.booleanCast(RT.get(nm.meta(), staticKey));
38773887
form = RT.cons(FN, RT.next(RT.next(form)));

0 commit comments

Comments
 (0)