Skip to content

Commit 2e7e41c

Browse files
committed
install default lookup thunk for non-field accessors of IKeywordLookups
1 parent 73d51ae commit 2e7e41c

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/jvm/clojure/lang/KeywordLookupSite.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,7 @@ public Object fault(Object target, ILookupHost host){
2929
}
3030
else if(target instanceof ILookup)
3131
{
32-
final Class c = target.getClass();
33-
host.swapThunk(n,new ILookupThunk(){
34-
35-
public Object get(Object target){
36-
if(target != null && target.getClass() == c)
37-
return ((ILookup) target).valAt(k);
38-
return this;
39-
}
40-
});
32+
host.swapThunk(n,ilookupThunk(target.getClass()));
4133
return ((ILookup) target).valAt(k);
4234
}
4335
host.swapThunk(n,this);
@@ -50,9 +42,24 @@ public Object get(Object target){
5042
return RT.get(target,k);
5143
}
5244

45+
private ILookupThunk ilookupThunk(final Class c){
46+
return new ILookupThunk(){
47+
public Object get(Object target){
48+
if(target != null && target.getClass() == c)
49+
return ((ILookup) target).valAt(k);
50+
return this;
51+
}
52+
};
53+
}
54+
5355
private Object install(Object target, ILookupHost host){
5456
ILookupThunk t = ((IKeywordLookup)target).getLookupThunk(k);
55-
host.swapThunk(n,t);
56-
return t.get(target);
57+
if(t != null)
58+
{
59+
host.swapThunk(n,t);
60+
return t.get(target);
61+
}
62+
host.swapThunk(n,ilookupThunk(target.getClass()));
63+
return ((ILookup) target).valAt(k);
5764
}
5865
}

0 commit comments

Comments
 (0)