Libraryless. Click here for Pure Java version (259L/2K).
1 | // returns Int.MAX_VALUE if not applicable |
2 | // returns -score if conversions are needed |
3 | // or +score if no conversions are needed |
4 | // Lower score is better |
5 | // assumes no arguments are null |
6 | static int methodApplicabilityScore_withPrimitiveWidening_onTypes(Executable m, Class[] argTypes) {
|
7 | Class<?>[] types = m.getParameterTypes(); |
8 | if (types.length != l(argTypes)) ret Int.MAX_VALUE; |
9 | int score = 0; |
10 | bool widenings; |
11 | for (int i = 0; i < types.length; i++) {
|
12 | Class t = argTypes[i]; |
13 | Class c = types[i]; |
14 | |
15 | int s = typeConversionScoreWithUnboxing(t, c); |
16 | printVars ifdef typeConversionScore_debug("typeConversionScoreWithUnboxing", +t, +c, +s);
|
17 | |
18 | if (s == Int.MAX_VALUE) |
19 | ret Int.MAX_VALUE; |
20 | if (s < 0) set widenings; |
21 | score += abs(s); |
22 | } |
23 | |
24 | ret widenings ? -score : score; |
25 | } |
Began life as a copy of #1034746
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1035462 |
| Snippet name: | methodApplicabilityScore_withPrimitiveWidening_onTypes |
| Eternal ID of this version: | #1035462/4 |
| Text MD5: | 7a11343681743768419e71f4211cb7ef |
| Transpilation MD5: | b0434d9442d895847f841a62750799e2 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-05-21 16:38:39 |
| Source code size: | 842 bytes / 25 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 363 / 468 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |