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

Unified extension methods #9255

Merged
merged 38 commits into from
Jul 6, 2020
Merged

Commits on Jul 4, 2020

  1. Unified extension methods

    Dotty currently uses three syntactically different schemes for extension methods
    
     1. Single methods with prefix parameters such as `def (x: T).f(y: U)` or `def (x: T) op (y: U)`.
        These methods can be abstract, can override each other, etc, which is crucial for infix ops
        in type classes.
     2. Given instances defining (only) extension methods with syntax `extension ops { ... }`
     3. Collective extension methods with syntax `extension on (x: T) { ... }`
    
    This PR proposes another scheme that unifies (1) and (3) and all but eliminates the need for (2).
    
    The simplification is achieved by redefining many fundamentals of extension methods. In a sense,
    the price we pay for user-facing simplifications is a more complex implementation scheme. But that's
    probably a price worth paying.
    
    The first commit is docs only. I updated the doc pages for extension methods, type classes, and
    the grammar.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    3cc3745 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d88a796 View commit details
    Browse the repository at this point in the history
  3. Doc fixes

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    f0c2e19 View commit details
    Browse the repository at this point in the history
  4. Desugaring of extensions

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    f87ec07 View commit details
    Browse the repository at this point in the history
  5. Doc fixes

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    e5ca6d5 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    02de5dc View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    70d5ec8 View commit details
    Browse the repository at this point in the history
  8. Update semanticDB expect files

    We should check that semanticDB does the right thing for extension methods
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    28ef7b6 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    74865c3 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    4c50dbd View commit details
    Browse the repository at this point in the history
  11. Look for extension methods directly in implicit scope

    Look for extension methods also directly in the objects that make up
    an implicit scope.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    5b1a2f7 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    71a853a View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    fb93f46 View commit details
    Browse the repository at this point in the history
  14. Make type parameters after extension method def illegal

    We'd have to at least check that there's no use before definition.
    Forbid for now, and come back once we support multiple type parameter
    clauses.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    1ad5ee9 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    6ff0ac8 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    c148218 View commit details
    Browse the repository at this point in the history
  17. Fix test

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    330c32f View commit details
    Browse the repository at this point in the history
  18. Disable check file for missing-implicit

    CI makes more suggestions than local on bootstrapped tests. I am not sure why. It might have to do with
    different setups what packages are forced and what not.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    b63da92 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    3e89b56 View commit details
    Browse the repository at this point in the history
  20. Fix extension method search in implicit scope

    The case where a scope contained only extension methods but no
    other givens was mishandled.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    a7213cc View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    00cc25d View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    5cdb3da View commit details
    Browse the repository at this point in the history
  23. Drop outdated repl test

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    ce6d9ca View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    40667a6 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    3188b43 View commit details
    Browse the repository at this point in the history
  26. Handle missing case for extension/conversion ambiguity

    If a candidate can be both a conversion and an extension, which
    happens if it is overloaded, and the extension is not applicable,
    try the conversion.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    2cd1092 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    8529885 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    c1b5150 View commit details
    Browse the repository at this point in the history
  29. Drop check file

    Check files should be only added if they test a tricky error message, typically
    one with lots of configurable parts. A simple string error message should never
    lead to a check file. Having too many check file just causes unnecessary friction for
    me and the other maintainers.
    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    e33d36f View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    026b58a View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    01ec288 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    17a8026 View commit details
    Browse the repository at this point in the history
  33. Add test

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    7de235d View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    4aae35c View commit details
    Browse the repository at this point in the history
  35. Address review comments

    odersky committed Jul 4, 2020
    Configuration menu
    Copy the full SHA
    c8d7be1 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    a128dab View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    b179a8e View commit details
    Browse the repository at this point in the history

Commits on Jul 5, 2020

  1. Allow optional : in extension

    There's will probably be a tendency to put a `:` in a collective extension
    by analogy to given and object, trait etc. We don't need to be picky about
    this.
    odersky committed Jul 5, 2020
    Configuration menu
    Copy the full SHA
    e160140 View commit details
    Browse the repository at this point in the history