Deep symbol-aware comparator in ImTranslator.sortEverything & stable TypeId #3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
ImTranslator.sortEverything():sortList(imProg.getFunctions())sorts usingComparator.comparing(this::getQualifiedClassName). However,FuncDefis not aNamedScope. All functions in packagePreturn the identical key"P_", and synthetic functions return"". BecauseList.sortis stable, functions within a package preserve their arbitrary file-discovery order.TypeIdAssignment:TypeId.calculatesorts classes withComparator.comparing(ImClass::getName).thenComparing(TypeId::packageName). Closure classes are all named"Closure", causing ties that fall back to unstable list order.RemoveGarbage.javausesHashMultimap<ImClass, ImMethod> waitingMethodsandHashSet<ImFunction>. Iterating throughwaitingMethods.get(c)yields methods inSystem.identityHashCode()order, which varies run-to-run.Implementation Tasks
ImTranslator.sortListcomparator to compare fully qualified mangled name, return type, and parameter signature.TypeId, removing sequential assignment ties.HashSet,HashMap, andHashMultimapinRemoveGarbage,ImOptimizer, andLuaTranslatorwithLinkedHashSet,LinkedHashMap, andTreeSet/TreeMap.