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

19
LINES

< > BotCompany Repo | #1034755 // typeConversionScoreWithUnboxing

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

Transpiled version (131L) is out of date.

// Can a be converted to b?

// score 0 = exact match
// score Int.MAX_VALUE = no match
// score 1 = conversion needed (boxing/unboxing or non-primitve widening)
// score -2 = primitive widening needed

static int typeConversionScoreWithUnboxing(Class a, Class b) {
  int score = typeConversionScore(a, b);
  if (score == 0 || score == 1) ret score;
  
  Class aPrim = boxedToPrimitiveType(a);
  if (aPrim != null) {
    int score2 = typeConversionScore(aPrim, b);
    if (score2 == 0) ret 1;
    else if (score2 != Int.MAX_VALUE) ret score2;
  }
  ret score;
}

Author comment

Began life as a copy of #1034747

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034755
Snippet name: typeConversionScoreWithUnboxing
Eternal ID of this version: #1034755/6
Text MD5: 1113801f2f7b71c0cd591459d8fb22cc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 03:47:52
Source code size: 579 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 132 / 206
Version history: 5 change(s)
Referenced in: [show references]