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

[WIP] Import missing given instance #4177

Closed
wants to merge 1 commit into from

Conversation

tanishiking
Copy link
Member

@tanishiking tanishiking commented Jul 21, 2022

refer to scalameta/metals-feature-requests#141

This PR enables us to import missing given instance

import-given

TODO

  • parse top-level given
  • testing

There're some limitations:

  • we don't filter missing instances by type, so if there's stringOrd: Ord[String], we will receive suggestions both for intOrd and stringOrd, I'm wondering can we filter it with a reasonable computation cost 🤔
  • if there's no explicit method definition under the given instances
    • for example, we can't find lt and gt because they're not under given instances.
trait Ord[T]:
  def compare(x: T, y: T): Int
  extension (x: T) def lt (y: T): Boolean = compare(x, y) > 0
  extension (x: T) def gt (y: T): Boolean = compare(x, y) < 0

given intOrd: Ord[Int] with
  def compare(x: Int, y: Int): Int = if x < y then 1 else -1

@tanishiking tanishiking marked this pull request as draft July 21, 2022 05:59
@tanishiking
Copy link
Member Author

I think this PR needs some rework, closing for now

@tanishiking tanishiking closed this Sep 7, 2022
@tanishiking tanishiking deleted the given-instances branch September 7, 2022 05:01
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

Successfully merging this pull request may close these issues.

1 participant