From b6b20d572ee5e25cc61bd6f65652b5c50832bd6d Mon Sep 17 00:00:00 2001 From: Ben Smith-Mannschott Date: Sat, 15 Oct 2011 17:08:13 +0200 Subject: [PATCH 1/2] CLJ-852: add regression test --- src/script/run_tests.clj | 1 + test/clojure/test_clojure/clj_852.clj | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) create mode 100644 test/clojure/test_clojure/clj_852.clj diff --git a/src/script/run_tests.clj b/src/script/run_tests.clj index 6720abd..5754d8f 100644 --- a/src/script/run_tests.clj +++ b/src/script/run_tests.clj @@ -10,6 +10,7 @@ clojure.test-clojure.clojure-xml clojure.test-clojure.clojure-zip clojure.test-clojure.compilation clojure.test-clojure.control +clojure.test-clojure.clj-852 clojure.test-clojure.data clojure.test-clojure.data-structures clojure.test-clojure.def diff --git a/test/clojure/test_clojure/clj_852.clj b/test/clojure/test_clojure/clj_852.clj new file mode 100644 index 0000000..c4602cf --- /dev/null +++ b/test/clojure/test_clojure/clj_852.clj @@ -0,0 +1,23 @@ +; Copyright (c) Rich Hickey. All rights reserved. +; The use and distribution terms for this software are covered by the +; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +; which can be found in the file epl-v10.html at the root of this distribution. +; By using this software in any fashion, you are agreeing to be bound by +; the terms of this license. +; You must not remove this notice, or any other, from this software. + +(ns clojure.test-clojure.clj-852 + (:use clojure.test clojure.test-helper + clojure.test-clojure.protocols)) + +(deftest clj-852 + (testing "IllegalArgumentException should not be thrown" + (testing "when defining var whose value is calculated with a primitive fn." + (testing "This case fails without a fix for CLJ-852" + (is (eval-in-temp-ns + (defn foo ^long [^long x] x) + (def x (inc (foo 10)))))) + (testing "This case should pass even without a fix for CLJ-852" + (is (eval-in-temp-ns + (defn foo ^long [^long x] x) + (def x (foo (inc 10))))))))) -- 1.7.7 From 4b89480c40820603ca982b8505bf1b894497bec6 Mon Sep 17 00:00:00 2001 From: Ben Smith-Mannschott Date: Sat, 15 Oct 2011 21:55:52 +0200 Subject: [PATCH 2/2] =?UTF-8?q?CLJ-852:=20add=20special=20cases=20for=20"int?= =?UTF-8?q?"=E2=80=A6"boolean"=20to=20tagToClass()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This causes the test to pass. --- src/jvm/clojure/lang/Compiler.java | 41 +++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index d41624d..18a78c6 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -938,7 +938,8 @@ static public abstract class HostExpr implements Expr, MaybePrimitiveExpr{ c = RT.classForName(sym.name); } catch(Exception e){ - //aargh + // aargh + // leave c set to null -> return null } } } @@ -985,17 +986,33 @@ static public abstract class HostExpr implements Expr, MaybePrimitiveExpr{ else if(sym.name.equals("longs")) c = long[].class; else if(sym.name.equals("floats")) - c = float[].class; - else if(sym.name.equals("doubles")) - c = double[].class; - else if(sym.name.equals("chars")) - c = char[].class; - else if(sym.name.equals("shorts")) - c = short[].class; - else if(sym.name.equals("bytes")) - c = byte[].class; - else if(sym.name.equals("booleans")) - c = boolean[].class; + c = float[].class; + else if(sym.name.equals("doubles")) + c = double[].class; + else if(sym.name.equals("chars")) + c = char[].class; + else if(sym.name.equals("shorts")) + c = short[].class; + else if(sym.name.equals("bytes")) + c = byte[].class; + else if(sym.name.equals("booleans")) + c = boolean[].class; + else if(sym.name.equals("int")) + c = Integer.TYPE; + else if(sym.name.equals("long")) + c = Long.TYPE; + else if(sym.name.equals("float")) + c = Float.TYPE; + else if(sym.name.equals("double")) + c = Double.TYPE; + else if(sym.name.equals("char")) + c = Character.TYPE; + else if(sym.name.equals("short")) + c = Short.TYPE; + else if(sym.name.equals("byte")) + c = Byte.TYPE; + else if(sym.name.equals("boolean")) + c = Boolean.TYPE; } } if(c != null) -- 1.7.7