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

Type hints should evaluate type matches with known arguments #413

Open
belamenso opened this issue Jan 10, 2025 · 2 comments
Open

Type hints should evaluate type matches with known arguments #413

belamenso opened this issue Jan 10, 2025 · 2 comments

Comments

@belamenso
Copy link

Is your feature request related to a problem? Please describe.

Scala 3.6.2. Consider this code

import scala.Tuple

class Container[Rs <: Tuple] {
  def guard(a: Tuple.Tail[Rs]): Unit = ()
}

@main def main(): Unit =
  Container[(1,2,3)].guard(null)

Hover with mouse in Metals-enabled VS Code at the word guard in the main function. You will see a type hint of this method

def guard(a: Tail[(1, 2, 3)]): Unit

This is not ideal because the type contains unevaluated type matches like Tuple.Tail that depend on entirely known types.

Describe the solution you'd like

I would like to see this type simplified to

def guard(a: (2, 3)): Unit

Describe alternatives you've considered

I do not know of alternative solutions to simplifying such expressions.

Additional context

No response

Search terms

type hint, type match, simplification

@belamenso belamenso changed the title Type hints should evaluate type matches inside Type hints should evaluate type matches when arguments are literal types Jan 10, 2025
@belamenso belamenso changed the title Type hints should evaluate type matches when arguments are literal types Type hints should evaluate type matches when arguments are known Jan 10, 2025
@belamenso belamenso changed the title Type hints should evaluate type matches when arguments are known Type hints should evaluate type matches with known arguments Jan 10, 2025
@tgodzik
Copy link
Contributor

tgodzik commented Jan 10, 2025

Thanks for reporting! I don't even know if that is possible, will need to ask around the compiler.

@belamenso
Copy link
Author

I also link an almost identical issue I opened against the compiler but in the context of displaying error messages: scala/scala3#22333

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

2 participants