Commit dc18ed2
committed
CLJS-2901: Return type inference for multi-arity & variadic fns
For the anonymous fn case simply handle the tagging of :methods in
cljs.analyzer/infer-type. This is enough for local fn invoke to be
be inferred correctly.
The top-level case is a bit trickier due to the fact that defn
is a ClojureScript macro that desugars before the compiler to ensure
that Closure cross module code motion can work. In this case add a
special case to cljs.analyzer/parse 'set!. If we have a top level
fn (:top-fn), use its metadata to recover the original fn information
pre-desugaring. :tag information comes from analyzing the body.
cljs.analyzer/infer-invoke has been changed to prefer inference over
:ret-tag.
In all cases we make sure enough `:methods` information is available
for infer-invoke to work.
Tweak cljs.analyzer/analyze-form-seq so that it's a bit more useful
under testing.
Add basic tests cases for the above as well as bringing back a large
number of inference tests that were commented out.1 parent 7d3b94d commit dc18ed2
4 files changed
Lines changed: 272 additions & 104 deletions
File tree
- src
- main
- cljs/cljs
- clojure/cljs
- test/clojure/cljs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
1820 | | - | |
| 1820 | + | |
1821 | 1821 | | |
1822 | 1822 | | |
1823 | 1823 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1346 | 1346 | | |
1347 | 1347 | | |
1348 | 1348 | | |
1349 | | - | |
1350 | | - | |
1351 | | - | |
1352 | | - | |
1353 | | - | |
1354 | | - | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
1355 | 1352 | | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1359 | 1358 | | |
1360 | 1359 | | |
1361 | 1360 | | |
| |||
2101 | 2100 | | |
2102 | 2101 | | |
2103 | 2102 | | |
| 2103 | + | |
| 2104 | + | |
2104 | 2105 | | |
2105 | 2106 | | |
2106 | 2107 | | |
| |||
2267 | 2268 | | |
2268 | 2269 | | |
2269 | 2270 | | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
2270 | 2285 | | |
2271 | 2286 | | |
2272 | 2287 | | |
| |||
3723 | 3738 | | |
3724 | 3739 | | |
3725 | 3740 | | |
3726 | | - | |
3727 | | - | |
| 3741 | + | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
| 3746 | + | |
| 3747 | + | |
| 3748 | + | |
3728 | 3749 | | |
3729 | | - | |
3730 | | - | |
3731 | | - | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
3732 | 3753 | | |
3733 | 3754 | | |
3734 | 3755 | | |
| |||
4305 | 4326 | | |
4306 | 4327 | | |
4307 | 4328 | | |
| 4329 | + | |
| 4330 | + | |
4308 | 4331 | | |
4309 | 4332 | | |
4310 | 4333 | | |
4311 | 4334 | | |
4312 | 4335 | | |
4313 | 4336 | | |
4314 | 4337 | | |
4315 | | - | |
| 4338 | + | |
4316 | 4339 | | |
4317 | 4340 | | |
4318 | 4341 | | |
4319 | 4342 | | |
4320 | 4343 | | |
4321 | | - | |
4322 | | - | |
4323 | | - | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
4324 | 4349 | | |
4325 | 4350 | | |
4326 | 4351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3055 | 3055 | | |
3056 | 3056 | | |
3057 | 3057 | | |
3058 | | - | |
| 3058 | + | |
| 3059 | + | |
3059 | 3060 | | |
3060 | 3061 | | |
3061 | 3062 | | |
| |||
3080 | 3081 | | |
3081 | 3082 | | |
3082 | 3083 | | |
| 3084 | + | |
3083 | 3085 | | |
3084 | 3086 | | |
3085 | 3087 | | |
3086 | | - | |
| 3088 | + | |
| 3089 | + | |
3087 | 3090 | | |
3088 | 3091 | | |
3089 | | - | |
| 3092 | + | |
| 3093 | + | |
3090 | 3094 | | |
3091 | | - | |
| 3095 | + | |
3092 | 3096 | | |
3093 | 3097 | | |
3094 | 3098 | | |
3095 | 3099 | | |
3096 | 3100 | | |
3097 | 3101 | | |
3098 | 3102 | | |
3099 | | - | |
| 3103 | + | |
3100 | 3104 | | |
3101 | 3105 | | |
3102 | 3106 | | |
| |||
3117 | 3121 | | |
3118 | 3122 | | |
3119 | 3123 | | |
3120 | | - | |
| 3124 | + | |
3121 | 3125 | | |
3122 | 3126 | | |
| 3127 | + | |
| 3128 | + | |
3123 | 3129 | | |
3124 | | - | |
| 3130 | + | |
| 3131 | + | |
3125 | 3132 | | |
3126 | 3133 | | |
3127 | 3134 | | |
| |||
3135 | 3142 | | |
3136 | 3143 | | |
3137 | 3144 | | |
| 3145 | + | |
3138 | 3146 | | |
3139 | 3147 | | |
3140 | 3148 | | |
3141 | | - | |
| 3149 | + | |
| 3150 | + | |
3142 | 3151 | | |
3143 | 3152 | | |
3144 | 3153 | | |
3145 | 3154 | | |
3146 | | - | |
| 3155 | + | |
| 3156 | + | |
3147 | 3157 | | |
3148 | 3158 | | |
3149 | 3159 | | |
3150 | | - | |
| 3160 | + | |
3151 | 3161 | | |
3152 | 3162 | | |
3153 | 3163 | | |
| |||
3165 | 3175 | | |
3166 | 3176 | | |
3167 | 3177 | | |
3168 | | - | |
| 3178 | + | |
3169 | 3179 | | |
3170 | 3180 | | |
3171 | 3181 | | |
| |||
0 commit comments