Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix class ordering when propagating type annotations, take two #352

Merged
merged 1 commit into from
Feb 12, 2024

Commits on Feb 12, 2024

  1. Fix class ordering when propagating type annotations, take two

    To propagate type annotations across nested classes, we sort the entire
    set of indexed classes so that outer classes come before their inner
    classes. We don't really care about ordering between classes that are
    not members of the same nest (using the JEP 181 terminology). That is,
    we only need a partial order on classes.
    
    However, to perform that sort, we use the sorting routine in the JDK, which
    uses the order defined by a `Comparator`, and that order must be total.
    
    To define a total order, this commit takes a completely opposite approach.
    We compute a nesting level for each class (where a top-level class has
    a nesting level of 0, a class nested in a top-level class has a nesting
    level of 1, etc.) and sort by the nesting level. For equal nesting levels,
    we sort by the class name. This means that all top-level classes come first,
    all classes nested in top-level classes come second, etc.
    
    To verify that a given `Comparator` establishes a total order for a given
    set of values, this commit includes a simple utility class `TotalOrderChecker`,
    which was used to reproduce (and understand) the problem of previous
    implementation of this ordering.
    Ladicek committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    6413798 View commit details
    Browse the repository at this point in the history