Exactly because the variance annotations make Function[Any, String]
a subtype of Function[String, Any]
.
The covariance annotation, +
means a narrower type argument yields a narrower constructed type and the contravariance annotation -
, means a wider type parameter yields a narrower constructed type.