Skip to content

Commit

Permalink
#CLJ-789 properly clear "tied" flag when exact method signature is av…
Browse files Browse the repository at this point in the history
…ailable

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
cemerick authored and stuarthalloway committed May 27, 2011
1 parent f81170d commit 62c4320
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<property name="src" location="src"/>
<property name="test" location="test"/>
<property name="jsrc" location="${src}/jvm"/>
<property name="jtestsrc" location="${test}/java"/>
<property name="cljsrc" location="${src}/clj"/>
<property name="cljscript" location="${src}/script"/>
<property name="test-script" location="${cljscript}/run_tests.clj"/>
Expand Down Expand Up @@ -77,6 +78,8 @@
unless="maven.test.skip">
<delete dir="${test-classes}"/>
<mkdir dir="${test-classes}"/>
<javac srcdir="${jtestsrc}" destdir="${test-classes}" includeJavaRuntime="yes"
debug="true" target="1.5" includeantruntime="no"/>
<java classname="clojure.lang.Compile"
classpath="${test-classes}:${test}:${build}:${cljsrc}"
failonerror="true"
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<directory>src/clj</directory>
</resource>
</resources>
<testSourceDirectory>test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
1 change: 1 addition & 0 deletions src/jvm/clojure/lang/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,7 @@ static int getMatchingParams(String methodName, ArrayList<Class[]> paramlists, I
{
if(!foundExact || matchIdx == -1 || rets.get(matchIdx).isAssignableFrom(rets.get(i)))
matchIdx = i;
tied = false;
foundExact = true;
}
else if(match && !foundExact)
Expand Down
9 changes: 8 additions & 1 deletion test/clojure/test_clojure/compilation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@


(ns clojure.test-clojure.compilation
(:use clojure.test))
(:use clojure.test)
(:import compilation.TestDispatch))

; http://clojure.org/compilation

Expand Down Expand Up @@ -73,3 +74,9 @@
(recur (dec x))))
3)))
(catch Exception _)))))

(deftest test-numeric-dispatch
(is (= "(int, int)" (TestDispatch/someMethod (int 1) (int 1))))
(is (= "(int, long)" (TestDispatch/someMethod (int 1) (long 1))))
(is (= "(long, long)" (TestDispatch/someMethod (long 1) (long 1)))))

15 changes: 15 additions & 0 deletions test/java/compilation/TestDispatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package compilation;

public class TestDispatch {
public static String someMethod (int a, int b) {
return "(int, int)";
}

public static String someMethod (int a, long b) {
return "(int, long)";
}

public static String someMethod (long a, long b) {
return "(long, long)";
}
}

0 comments on commit 62c4320

Please sign in to comment.