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

Plug many variance holes (in higher-kinded types, refined types and private inner classes) #8545

Merged
merged 4 commits into from Mar 19, 2020

Commits on Feb 8, 2020

  1. Plug many variance holes (pos and neg)

    The variance checks root in `RefChecks` for `TypeTree`s is modified
    to check only the variance of `PolyType`s (this includes type lambdas).
    Checking the definition of the `PolyType`s' owners is not correct,
    because `relativeVariance` doesn't work for types in arbitrary position.
    
    To check the variance of `PolyType`s we introduce a new type map:
    `PolyTypeVarianceMap`. This is similar to the way variance is checked
    for type lambdas in dotty, where type lambdas are encoded explicitly.
    
    We also add explicit tracking for lower bounds of `PolyType`s.
    For a type parameter of a `PolyType`, the variance should not be
    flipped (or equivalently, flipped twice) in the lower bound.
    This applies to both `ValidateVarianceMap` and `PolyTypeVarianceMap`.
    It fixes variance bugs for types appering in the bounds of HKTs.
    
    Finally, we don't skip local definitions entirely (this is unsound),
    but instead cutoff `relativeVariance` at local boundaries.
    joroKr21 committed Feb 8, 2020
    Configuration menu
    Copy the full SHA
    a13cee2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d7b572e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0765176 View commit details
    Browse the repository at this point in the history
  4. Variances: replace lowerBoundStack with a single flag

    Add documentation to the two different variance validation methods:
    `validateDefinition` and `validateVarianceOfPolyTypesIn`.
    joroKr21 committed Feb 8, 2020
    Configuration menu
    Copy the full SHA
    a29da6a View commit details
    Browse the repository at this point in the history