summaryrefslogtreecommitdiff
path: root/src/jvm/clojure
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-05-28 14:50:12 +0000
committerRich Hickey <richhickey@gmail.com>2008-05-28 14:50:12 +0000
commit4173ff7ccc0079dac061bbbbed29445696599844 (patch)
tree181805790069c86ab727ccc20215cb8d95293309 /src/jvm/clojure
parent69e5e3659b7cb45433333bd501cc82a4893cc3df (diff)
improved overload resolution
Diffstat (limited to 'src/jvm/clojure')
-rw-r--r--src/jvm/clojure/lang/Compiler.java21
-rw-r--r--src/jvm/clojure/lang/Reflector.java1
2 files changed, 14 insertions, 8 deletions
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java
index e62fcc08..1d05bda2 100644
--- a/src/jvm/clojure/lang/Compiler.java
+++ b/src/jvm/clojure/lang/Compiler.java
@@ -1756,14 +1756,19 @@ static class ClassExpr implements Expr{
static boolean subsumes(Class[] c1, Class[] c2){
//presumes matching lengths
+ Boolean better = false;
for(int i = 0; i < c1.length; i++)
{
- if(c2[i].isPrimitive() && c1[i] == Object.class)
- continue;
- if(!c2[i].isAssignableFrom(c1[i]))
- return false;
+ if(!(c1[i] == c2[i] || c2[i].isPrimitive() && c1[i] == Object.class))
+ {
+ if(c1[i].isPrimitive() && c2[i] == Object.class
+ || c2[i].isAssignableFrom(c1[i]))
+ better = true;
+ else
+ return false;
+ }
}
- return true;
+ return better;
}
static int getMatchingParams(String methodName, ArrayList<Class[]> paramlists, IPersistentVector argexprs)
@@ -2967,7 +2972,7 @@ static class FnMethod{
}
void emitClearLocals(GeneratorAdapter gen){
- for(int i = 1; i < numParams()+1; i++)
+ for(int i = 1; i < numParams() + 1; i++)
{
if(!localsUsedInCatchFinally.contains(i))
{
@@ -3355,7 +3360,7 @@ static public class CompilerException extends Exception{
static public Var isMacro(Object op) throws Exception{
//no local macros for now
- if(op instanceof Symbol && referenceLocal((Symbol)op) != null)
+ if(op instanceof Symbol && referenceLocal((Symbol) op) != null)
return null;
if(op instanceof Symbol || op instanceof Var)
{
@@ -3372,7 +3377,7 @@ static public Var isMacro(Object op) throws Exception{
static public IFn isInline(Object op) throws Exception{
//no local inlines for now
- if(op instanceof Symbol && referenceLocal((Symbol)op) != null)
+ if(op instanceof Symbol && referenceLocal((Symbol) op) != null)
return null;
if(op instanceof Symbol || op instanceof Var)
{
diff --git a/src/jvm/clojure/lang/Reflector.java b/src/jvm/clojure/lang/Reflector.java
index 5c43566d..47dc1b41 100644
--- a/src/jvm/clojure/lang/Reflector.java
+++ b/src/jvm/clojure/lang/Reflector.java
@@ -255,6 +255,7 @@ static public List getMethods(Class c, int arity, String name, boolean getStatic
{
if(name.equals(allmethods[i].getName())
&& Modifier.isStatic(allmethods[i].getModifiers()) == getStatics
+ && !Modifier.isVolatile(allmethods[i].getModifiers())
&& allmethods[i].getParameterTypes().length == arity)
{
methods.add(allmethods[i]);