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

A lint rule for M[_] <: List[_] #906

Closed
dwijnand opened this issue Nov 8, 2018 · 2 comments
Closed

A lint rule for M[_] <: List[_] #906

dwijnand opened this issue Nov 8, 2018 · 2 comments

Comments

@dwijnand
Copy link
Contributor

dwijnand commented Nov 8, 2018

See https://github.com/lampepfl/dotty/issues/1809, it would be lovely to have a lint rule for this.

@Jacoby6000
Copy link
Contributor

Jacoby6000 commented Nov 16, 2018

Until this is an official rule, you can this pattern:

(\w+)\[_\]\s*<:\s*(\w+)\[_\]

and after #907 gets merged, you can use

{
  "id" = "hktSubtypeOfExistential"
  "pattern" = "(\\w+)\\[_\\]\\s*<:\\s*(\\w+)\\[_\\]"
  "message" = "{$0} is attempting to express a higher-kinded type as a subtype of an existential type.  You probably meant {$1}[X] <: {$2}[X]"
}

To get a nicely detailed error message

@olafurpg
Copy link
Contributor

olafurpg commented Nov 28, 2018

Thank you for reporting, this is a good idea! I've hit on it myself. I think it's best that this linter gets implemented as a custom rule so that it can evolve separately from the Scalafix core APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants