From dcc170f289841c73182a0cd6e5e43d937876e24c Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 27 Nov 2025 23:09:01 +0100 Subject: [PATCH] CLJS-3466: support qualified method in return position --- src/main/clojure/cljs/analyzer.cljc | 2 +- src/test/cljs/cljs/qualified_method_test.cljs | 17 +++++++++++++++++ src/test/cljs/lite_test_runner.cljs | 4 +++- src/test/cljs/test_runner.cljs | 4 +++- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/test/cljs/cljs/qualified_method_test.cljs diff --git a/src/main/clojure/cljs/analyzer.cljc b/src/main/clojure/cljs/analyzer.cljc index f1c337420..fc3fc4321 100644 --- a/src/main/clojure/cljs/analyzer.cljc +++ b/src/main/clojure/cljs/analyzer.cljc @@ -4141,7 +4141,7 @@ {:op :qualified-method :env env :form sym - :class (analyze-symbol env (symbol sym-ns))} + :class (analyze-symbol (assoc env :context :expr) (symbol sym-ns))} (if (= "new" sym-name) {:kind :new :name (symbol sym-name)} diff --git a/src/test/cljs/cljs/qualified_method_test.cljs b/src/test/cljs/cljs/qualified_method_test.cljs new file mode 100644 index 000000000..df339b6b8 --- /dev/null +++ b/src/test/cljs/cljs/qualified_method_test.cljs @@ -0,0 +1,17 @@ +; 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 cljs.qualified-method-test + (:refer-global :only [String]) + (:require [cljs.test :as test :refer-macros [deftest testing is]])) + +(deftest qualified-method-return-position-test + (testing "qualified method returned from function to force it in return position" + (let [f (fn [] String/.toUpperCase) + m (f)] + (is (= "FOO" (m "foo")))))) diff --git a/src/test/cljs/lite_test_runner.cljs b/src/test/cljs/lite_test_runner.cljs index 0b0c45b56..c9f58d677 100644 --- a/src/test/cljs/lite_test_runner.cljs +++ b/src/test/cljs/lite_test_runner.cljs @@ -7,7 +7,8 @@ ;; You must not remove this notice, or any other, from this software. (ns lite-test-runner - (:require [cljs.proxy-test] + (:require [cljs.qualified-method-test] + [cljs.proxy-test] [cljs.test :refer-macros [run-tests]] [cljs.apply-test] [cljs.primitives-test] @@ -73,6 +74,7 @@ (enable-console-print!)) (run-tests + 'cljs.qualified-method-test 'cljs.proxy-test 'cljs.apply-test 'cljs.primitives-test diff --git a/src/test/cljs/test_runner.cljs b/src/test/cljs/test_runner.cljs index 16a1cbf18..666e0ea82 100644 --- a/src/test/cljs/test_runner.cljs +++ b/src/test/cljs/test_runner.cljs @@ -7,7 +7,8 @@ ;; You must not remove this notice, or any other, from this software. (ns test-runner - (:require [cljs.proxy-test] + (:require [cljs.qualified-method-test] + [cljs.proxy-test] [cljs.test :refer-macros [run-tests]] [cljs.apply-test] [cljs.primitives-test] @@ -72,6 +73,7 @@ (enable-console-print!)) (run-tests + 'cljs.qualified-method-test 'cljs.proxy-test 'cljs.apply-test 'cljs.primitives-test