sbool preciseNuObject_debug; static A preciseNuObject(Class c, O... args) ctex { L methods = c.getDeclaredConstructors(); Constructor best = null; int bestScore = Int.MAX_VALUE; bool widening; if (preciseNuObject_debug) printVars("preciseNuObject", +c, methods := l(methods)); for (m : methods) { int score = methodApplicabilityScore_withPrimitiveWidening(m, args); if (score == 0) ret (A) invokeConstructor(m, args); if (preciseNuObject_debug) print("Method score: " + m + " " + score); if (abs(score) < bestScore) { best = m; bestScore = abs(score); widening = score < 0; } } if (best != null) if (widening) ret invokeConstructorWithWidening(best, args); else ret invokeConstructor(best, args); // try varargs - TODO: make this precise too methodSearch: for (m : methods) { continue unless m.isVarArgs(); O[] newArgs = massageArgsForVarArgsCall(m, args); if (newArgs != null) ret invokeConstructor(m, newArgs); } fail("No matching constructor found: " + formatFunctionCall(c, map _getClass(args))); }