Why are all type bounds not used when inferring type constructors?

66 Views Asked by At

Consider the abbreviated output of --explain-types on the following snippet

scala> :settings --explain-types

scala> def f[F[_ <: Int] <: List[_ <: Int], A <: Int](as: F[A]) = as
def f[F[_ <: Int] <: List[_ <: Int], A <: Int](as: F[A]): F[A]

scala> f(List(42))
...
  List[A] <: List[_ <: Int]?
    Nothing <: A?
    true
    A <: Int?
    false
    List[_$1] = List[_$1]?
    true
  false
...
       error: type mismatch;
        found   : List[Int]
        required: F[A]
List[Int] <: F[A]?
false

My interpretation is that List[A] <: List[_ <: Int]? is false because

A <: Int?
false

but is it not the case that this type bound is given right there in the type clause

def f[..., A <: Int]
           \______/   
              |
         why is it not using this type bound?

Why is it not using A <: Int when List[A] <: List[_ <: Int]? is not satisfied to then try say ?F := [A <: Int] =>> List[A] next?

0

There are 0 best solutions below