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

Try to instantiate type variables in tryInsertImplicitOnQualifier #13884

Merged
merged 1 commit into from Nov 15, 2021

Commits on Nov 5, 2021

  1. Try to instantiate type variables in tryInsertImplicitOnQualifier

    Fixes scala#13842
    
    What happened in scala#13842 was that we were not hitting this case in
    `tryWiden`, which is a method in ApproximatingTypeMap that tries
    to dealias or widen before propagating a Range outwards:
    
    ```scala
              case info: SingletonType =>
                // if H#x: y.type, then for any x in L..H, x.type =:= y.type,
                // hence we can replace with y.type under all variances
                reapply(info)
    ```
    The actual info here was a TypeVar with a singleton type as lower bound. Instantiating
    the TypeVar produces a SingletonType and case applies.
    
    We cannot really instantiate TypeVars here since this is very low-level code. For instance
    we might be in a state where the instantiation is provisional and the TyperState is thrown
    away. But AsSeenFrom results are cached so we'd have the wrong type in the caches.
    
    What we do instead is add an additional case in `tryInsertImplicitOnQualifier` which is the
    last resort when an application fails. Here, if we can instantiate some type variables in the
    qualifier, we try again.
    odersky committed Nov 5, 2021
    Configuration menu
    Copy the full SHA
    3183820 View commit details
    Browse the repository at this point in the history