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

Fix upper bound constraints, that are higher-kinded #16744

Merged
merged 1 commit into from
Jan 23, 2023

Commits on Jan 22, 2023

  1. Fix upper bound constraints, that are higher-kinded

    When recording an upper bound, when it's a some higher-kinded type
    variable applied to some type arguments, TypeComparer was re-applying
    the type arguments to the type parameter (the type variable's origin).
    Meaning that the instantiation of the type variable won't reflect in the
    upper bound.
    
    See the error message: `F$1[Int]` correctly appears as the lower bound,
    but `F$1[Int]` isn't the upper bound, `F[Int]` is, which is the original
    type parameter, in `Foo.Bar.apply[F](..)`.
    
        -- [E007] Type Mismatch Error: i12478.scala:8:13 -------------------------------
        8 |      Foo.Bar(fu1)
          |      ^^^^^^^^^^^^
          |Found:    Foo.Bar[F$1]
          |Required: Foo[T1]
          |
          |where:    F$1 is a type in method id1 with bounds <: [_] =>> Any
          |          T1  is a type in method id1 with bounds >: F$1[Int] and <: F[Int]
          |
          | longer explanation available when compiling with `-explain`
        -- [E007] Type Mismatch Error: i12478.scala:18:13 ------------------------------
        18 |      Foo.Bar(fu3)
           |      ^^^^^^^^^^^^
           |Found:    Foo.Bar[F$2]
           |Required: Foo[T3]
           |
           |where:    F$2 is a type in method id3 with bounds <: [_] =>> Any
           |          T3  is a type in method id3 with bounds >: F$2[Int] and <: F[Int]
           |
           | longer explanation available when compiling with `-explain`
    dwijnand committed Jan 22, 2023
    Configuration menu
    Copy the full SHA
    c73c47a View commit details
    Browse the repository at this point in the history