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

28
LINES

< > BotCompany Repo | #1028400 // findMethods_precise_onTypes - better method resolution

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

Libraryless. Click here for Pure Java version (2581L/17K).

static L<Method> findMethods_precise_onTypes(O o, S method, Class... argTypes) ctex {
  if (o cast Class) {
    _MethodCache cache = callOpt_getCache(o);
    L<Method> methods = cache.cache.get(method);
    new Map<Method, Int> scores;
    if (methods != null) for (Method m : methods) {
      continue unless isStaticMethod(m);
      int score = methodApplicabilityScore_onTypes(m, argTypes);
      if (score < Int.MAX_VALUE) {
        /*if (preciseCall_debug)
          print("Method score: " + m + " " + score);*/
        scores.put(m, score);
      }
    }
    ret keysSortedByValue(scores);
  }
  
  if (o == null) null;
  _MethodCache cache = callOpt_getCache(o.getClass());
  L<Method> methods = cache.cache.get(method);
  new Map<Method, Int> best;
  if (methods != null) for (Method m : methods) {
    int score = methodApplicabilityScore_onTypes(m, argTypes);
    if (score < Int.MAX_VALUE)
      best.put(m, score);
  }
  ret keysSortedByValue(best);
}

Author comment

Began life as a copy of #1020934

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028400
Snippet name: findMethods_precise_onTypes - better method resolution
Eternal ID of this version: #1028400/1
Text MD5: 9094252303f499f70e33b61b1933d03f
Transpilation MD5: 062c8f188429c41e99ffd9c4426fc5fd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-16 01:44:40
Source code size: 992 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 199 / 298
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1036431 - findMethods_withPrimitiveWidening_onTypes - even better method resolution