dotty-feature-requests
dotty-feature-requests copied to clipboard
Emit a warning when parsing def foo[M[_] <: List[_]](...) as it is probably not what was intended
When someone write:
def foo[M[_] <: List[_]] = ???
They probably wanted to write:
def foo[M[X] <: List[X]] = ???
But were confused by the fact that _
means "higher-kinded type parameter" on the left of <:
but means "wildcard" on the right. Ideally we would deprecate this syntax but until and unless that happens we could detect this sort of case and warn. (If the user intended to bound his higher-kinded type by a wildcard application he can always write: def foo[M[X] <: List[_]]
or def foo[M <: [X] -> List[_]]
which are clearer).
Asides from the plan in #5379, it might be wonderful to have a lint rule, or if feasible a rewrite rule, for this. 🙂
This seems like it should be easily doable with a scalafix linting rule.