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

Drop requirement that self types are closed #16648

Merged
merged 3 commits into from
Jan 12, 2023
Merged

Commits on Jan 11, 2023

  1. Drop requirement that self types are closed

    scala#702 introduced a requirement that self types are closed. This means
    
    > If trait X has self type S and C is a class symbol of S, then S also conforms
    to the self type of C.
    
    An example that violates this requirement is
    ```scala
    trait X { self: Y => } // error: missing requirement: self type Y & X of trait X does not conform to self type Z of required trait Y
    trait Y { self: Z => }
    trait Z
    ```
    But it's no longer clear what the requirement should achieve. If we let the example above
    typecheck and try to implement X with something like
    ```scala
    class C extends X, Y
    ```
    we would at that point get an error saying that `C` does not conform to the self type Z of Y.
    So it would have to be
    ```scala
    class C extends X, Y, Z
    ```
    and this one looks fine.
    
    The original change in scala#702 was made to avoid a crash in pending/run/t7933.scala.
    Unfortunately, we cannot reproduce this anymore since it depends on nsc.interpreter,
    which is no longer part of Scala 2.13.
    
    Since we are no longer sure what the restriction should achieve I think it's better to
    drop it for now. If people discover problems with code that uses "open" self types, we
    can try to fix those problems, and if that does not work, would fallback re-instituting
    the restriction. It's not ideal, but I don't see another way.
    odersky committed Jan 11, 2023
    Configuration menu
    Copy the full SHA
    668f3eb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dd1e198 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    689a942 View commit details
    Browse the repository at this point in the history