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).

// second part of return value is whether primitive widening is required
static Pair<Method, Bool> findMethod_withPrimitiveWidening_onTypes(O o, S method, Class... argTypes) ctex {
  new Lowest<Method> best;
  bool widening;
  
  if (o cast Class) {
    _MethodCache cache = callOpt_getCache(o);
    L<Method> methods = cache.cache.get(method);
    if (methods != null) for (Method m : methods) {
      continue unless isStaticMethod(m);
      int score = methodApplicabilityScore_withPrimitiveWidening_onTypes(m, argTypes);
      print ifdef preciseCall_debug("Method score: " + m + " " + score);
      if (abs(score) < Int.MAX_VALUE) {
        best.put(m, abs(score));
        widening = score < 0;
      }
    }
    ret pair(best!, widening);
  }
  
  if (o == null) null;
  _MethodCache cache = callOpt_getCache(o.getClass());
  L<Method> methods = cache.cache.get(method);
  if (methods != null) for (Method m : methods) {
    int score = methodApplicabilityScore_withPrimitiveWidening_onTypes(m, argTypes);
    if (abs(score) < Int.MAX_VALUE) {
      best.put(m, abs(score));
      widening = score < 0;
    }
  }
  ret pair(best!, widening);
}

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: 127 / 179
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)