Skip to content

Commit

Permalink
Fix clj-kondo#1972: type hint aliases should not result in unresolved…
Browse files Browse the repository at this point in the history
… symbol
  • Loading branch information
borkdude committed Feb 8, 2023
1 parent b0dd500 commit 310f452
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For a list of breaking changes, check [here](#breaking-changes).
- [#1971](https://github.com/clj-kondo/clj-kondo/issues/1971): false positive `:redundant-fn-wrapper` with syntax-quoted body
- [#1984](https://github.com/clj-kondo/clj-kondo/issues/1984): lint java constructor calls as unresolved-symbol when using dot notation.
- [#1970](https://github.com/clj-kondo/clj-kondo/issues/1970): `:dynamic-var-not-earmuffed` should be opt-in
- [#1972](https://github.com/clj-kondo/clj-kondo/issues/1972): type hint aliases should not result in unresolved symbol

## 2023.01.20

Expand Down
13 changes: 12 additions & 1 deletion src/clj_kondo/impl/metadata.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@
:else {:tag s})))

(def type-hint-bindings
'{void {} objects {}})
"From https://clojure.org/reference/java_interop#TypeAliases"
(zipmap '[int ints
long longs
float floats
double doubles
void
short shorts
boolean boolean
byte bytes
char chars
objects]
(repeat {})))

(defn lift-meta-content2
([ctx node] (lift-meta-content2 ctx node false))
Expand Down
9 changes: 9 additions & 0 deletions test/clj_kondo/unresolved_symbol_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,12 @@

(is (empty? (lint! "(ns foo) (comment (map square [1 2 3])) (defn square [x] (* x x))"
{:linters {:unresolved-symbol {:level :error}}}))))

(deftest primitive-type-hints-test
(is (empty? (lint! "(ns my-app
(:refer-clojure :exclude [double int]))
(defn scalb
[x exp]
(Math/scalb ^double x ^int exp))"
{:linters {:unresolved-symbol {:level :error}}}))))

0 comments on commit 310f452

Please sign in to comment.