reiska.core=> (t/cf (long (+ 2 (int 123))))
Type Error (/private/var/folders/x2/47j5hlbs01b9b4mjz_8fyf05m8hy4p/T/form-init7340610759194794514.clj:1:7) Static method clojure.lang.RT/longCast could not be applied to arguments:
Domains:
long
Arguments:
t/AnyInteger
Ranges:
long
in: (clojure.lang.RT/longCast (clojure.lang.Numbers/add 2 (clojure.lang.RT/intCast 123)))
in: (clojure.lang.RT/longCast (clojure.lang.Numbers/add 2 (clojure.lang.RT/intCast 123)))
ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4403)
1. clojure.core/long is defined as an inlineable function, so its body gets inlined and core.typed never sees the function application (long x) (where long's type is [t/Any -> Long]). Instead, it sees the method application (clojure.lang.RT/longCast x) and has to infer the method's type from its Java type.
This hypothesis is supported by the following experiment. Commenting out the inline form in a copy of clojure.core/long makes it apply cleanly to t/AnyInteger values.
2. The clojure.lang.RT/longCast method is overloaded. It seems that instead of inferring a multi-arity type, core.typed seems to pick just one of the arities. In this case it picks the wrong arity: t/AnyInteger is a valid argument to longCast(Object x), but not the picked longCast(long x).
reiska.core=> (t/cf (long (+ 2 (int 123)))) Type Error (/private/var/folders/x2/47j5hlbs01b9b4mjz_8fyf05m8hy4p/T/form-init7340610759194794514.clj:1:7) Static method clojure.lang.RT/longCast could not be applied to arguments: Domains: long Arguments: t/AnyInteger Ranges: long in: (clojure.lang.RT/longCast (clojure.lang.Numbers/add 2 (clojure.lang.RT/intCast 123))) in: (clojure.lang.RT/longCast (clojure.lang.Numbers/add 2 (clojure.lang.RT/intCast 123))) ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4403)
Pull request: 36
Patch: ctyp-210.patch
Commit: 68d20b
Release: 0.3.9