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

Avoid cycle with top-level export and trait #13719

Merged
merged 1 commit into from Oct 8, 2021

Commits on Oct 8, 2021

  1. Avoid cycle with top-level export and trait

    Previously, the following lead to a cycle (typing the extension method
    requires typing its `Int` parameter, which forces completion of the
    package object containing the top-level definition, which forces
    completion of the extension method via the export clause):
    
        trait MyExtensions:
          extension (lhs: Int) def bash: Unit = {}
        object MyExtensions extends MyExtensions
    
        export MyExtensions.*
        val fails = 1.bash
    
    But curiously enough, simply defining `object MyExtensions` before
    `trait MyExtensions` was enough to work around the issue. This happened
    because typing the module val of the object forces the package object,
    this in turns forces the extension method but because of the way
    class completers work, this doesn't lead to a cycle.
    
    Based on this experiment, this commit simply always forces the package
    object before typing any definition in the package, so we don't run into
    a cycle no matter the order in which definitions appear.
    smarter committed Oct 8, 2021
    Configuration menu
    Copy the full SHA
    37d6d1e View commit details
    Browse the repository at this point in the history