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

Redesign Tuples with HList-like structure #2199

Closed
wants to merge 11 commits into from

Commits on May 1, 2017

  1. Configuration menu
    Copy the full SHA
    e1ef43d View commit details
    Browse the repository at this point in the history
  2. Implement HList based Tuples

    Changes are as follows:
    
    - New types for tuples in dotty library: Tuple = Unit | TupleCons Head Tail <: Tuple
    
    - Desugaring uses this structure instead of the scala.TupleN for types and expressions
    
    - New TupleRewrites phase does rewrites the HList structure into scala.TupleN like case classes (for small arities) or a case class wrapping an Array (for large arities)
    OlivierBlanvillain committed May 1, 2017
    Configuration menu
    Copy the full SHA
    00044b6 View commit details
    Browse the repository at this point in the history
  3. Erasure/Scala2Unpickler hacks to restore binary compatibility

    To stay binary compatibility with scala 2.11 binaries, we hijack the
    unpickling of types to fake an HList structure. Later on in erasure, HList
    types are eraised back to scala.TupleN (for N <= 22). In addition because the
    actual scala.TupleN classes are neither `<: Tuple` now `<: TupleCons`, these
    types needs to be systematically araised to Object.
    
    In addition to all these carefully compensating hacks, this also imposes a new
    contain: the dotty-library, which defines several `Tuple/TupleCons` methods,
    can should now *always* be compiled by dotty itself. Indeed, when compiled
    with scalac, these types will stay as they are instead of being eraised to
    Object.
    OlivierBlanvillain committed May 1, 2017
    Configuration menu
    Copy the full SHA
    1c0a088 View commit details
    Browse the repository at this point in the history
  4. Update Build.scala to always use dotty-library-bootstraped

    I couldn't get rid of the `dotty-library` project completely, it's still used the first time sbt-briged is compiled with dotty. The dependencies are as follows:
    
    - (no dep) compile `dotty-compile` with scalac [0]
    - (no dep) compile `dotty-library` with scalac [1]
    - ([0], [1]) → compile `dotty-sbt-bridge` with dotty [2]
    - ([0], [2]) → compile `dotty-library-bootstraped` with dotty + sbt
    
    After that, [1] should never be used again.
    OlivierBlanvillain committed May 1, 2017
    Configuration menu
    Copy the full SHA
    adb13ac View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9f4fca6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    69a402a View commit details
    Browse the repository at this point in the history
  7. Update tests after tuple changes

    - dotc/scala-collections.blacklist:
    
    Blacklist Unit and TupleN from scala-collections test
    
    - tests/neg/i1653.scala:
    
    Having an additional superclass on Unit seams to affect the error here (not sure why).
    
    - tests/pos/t0301.scala:
    
    Since `_2` is now added thought implicit conversion, the pattern used in this case is no longer stable.
    
    - tests/pos/tcpoly_bounds1.scala:
    
    This test uses the fact that `(A, B) <: Product2[A, B]`, which is no longer the case.
    
    - tests/repl/patdef.check:
    
    Having the `_i` via implicit conversions remove the @unchecked here
    
    - tests/run/tuple-match.scala:
    
    Replace Tuple1 in pattern matching with explicit TupleCons pattern. TupleN can still be used in apply position (defined as defs in DottyPredef), but not in unapply position.
    
    - tests/run/unapply.scala:
    
    Also uses the fact that `(A, B) <: Product2[A, B]`.
    
    - tests/run/withIndex.scala:
    
    Might be a limitation in typer?:
    
    14 |        case _: Array[Tuple2[_, _]] => true
       |                      ^^^^^^^^^^^^
       |unreducible application of higher-kinded type [A, B] => dotty.TupleCons[A, dotty.TupleCons[B, Unit]] to wildcard arguments
    OlivierBlanvillain committed May 1, 2017
    Configuration menu
    Copy the full SHA
    4058a9c View commit details
    Browse the repository at this point in the history
  8. Add tests for new the tuples

    The LogPendingSubTypesThreshold change is requires for tests on size ~25 tuples that would otherwise trigger -Yno-deep-subtypes
    OlivierBlanvillain committed May 1, 2017
    Configuration menu
    Copy the full SHA
    22ffef2 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0e477a0 View commit details
    Browse the repository at this point in the history
  10. Always publishLocal before tests

    Because all tests depend on dotty-library-bootstrapped publishLocal is always needed to run tests.
    OlivierBlanvillain committed May 1, 2017
    Configuration menu
    Copy the full SHA
    491947a View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    6c92389 View commit details
    Browse the repository at this point in the history