假设作为, letF[_ <: A] <: B
的类型级模拟,则不应键入 application yield when ,因此应在以下情况下编译f: A => B
[F[_ <: Int] <: List[Int], A <: Int]
F[A]
List[Int]
A = Int
f(List(42))
$ scala3-repl
scala> def f[F[_ <: Int] <: List[Int], A <: Int](as: F[A]) = as
def f[F[_$1] <: List[Int], A <: Int](as: F[A]): F[A]
scala> f(List(42))
1 |f(List(42))
| ^^^^^^^^
|Found: List[Int]
|Required: F[A]
|
|where: A is a type variable with constraint <: Int
| F is a type variable with constraint <: [_$1 <: Int] =>> List[Int]
通过显式提供类型参数应用错误消息使其工作
scala> f[[_ <: Int] =>> List[Int], Int](List(42))
val res0: List[Int] = List(42)
类比在哪里中断?我认为从错误到F[_ <: Int] <: List[Int]
类型级别函数的心智模型在哪里?Int
List[Int]