Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1035463 // findMethod_withPrimitiveWidening_onTypes - even better method resolution

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (8224L/46K).

1  
// second part of return value is whether primitive widening is required
2  
static Pair<Method, Bool> findMethod_withPrimitiveWidening_onTypes(O o, S method, Class... argTypes) ctex {
3  
  new Lowest<Method> best;
4  
  bool widening;
5  
  
6  
  if (o cast Class) {
7  
    _MethodCache cache = callOpt_getCache(o);
8  
    L<Method> methods = cache.cache.get(method);
9  
    if (methods != null) for (Method m : methods) {
10  
      continue unless isStaticMethod(m);
11  
      int score = methodApplicabilityScore_withPrimitiveWidening_onTypes(m, argTypes);
12  
      print ifdef preciseCall_debug("Method score: " + m + " " + score);
13  
      if (abs(score) < Int.MAX_VALUE) {
14  
        best.put(m, abs(score));
15  
        widening = score < 0;
16  
      }
17  
    }
18  
    ret pair(best!, widening);
19  
  }
20  
  
21  
  if (o == null) null;
22  
  _MethodCache cache = callOpt_getCache(o.getClass());
23  
  L<Method> methods = cache.cache.get(method);
24  
  if (methods != null) for (Method m : methods) {
25  
    int score = methodApplicabilityScore_withPrimitiveWidening_onTypes(m, argTypes);
26  
    if (abs(score) < Int.MAX_VALUE) {
27  
      best.put(m, abs(score));
28  
      widening = score < 0;
29  
    }
30  
  }
31  
  ret pair(best!, widening);
32  
}

Author comment

Began life as a copy of #1020934

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035463
Snippet name: findMethod_withPrimitiveWidening_onTypes - even better method resolution
Eternal ID of this version: #1035463/1
Text MD5: 577d9b0f9a1241e4e2c8d2c133ffaef6
Transpilation MD5: 0969b50bd77766d2f201b6ce536e4a62
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-21 17:09:33
Source code size: 1183 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 126 / 178
Referenced in: [show references]