Skip to content

Disambiguate methods with different return types based on explicitly specified type parameter #4561

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

Closed
pweisenburger opened this issue May 22, 2018 · 2 comments

Comments

@pweisenburger
Copy link
Contributor

The following code compiles using Scala:

object abc {
  trait Test0
  trait Test1 { def apply(f: Int => Int): Unit }

  def v: Test0 = ???
  def v[T]: Test1 = ???

  v[Any] { v => v }
}

Dotty produces the following compiler error:

8 |  v[Any] { v => v }
  |           ^
  |missing parameter type
  |
  |The argument types of an anonymous function must be fully known. (SLS 8.5)
  |Expected type: ?
  |Missing type for parameter v
@nicolasstucki
Copy link
Contributor

Now it fails with

8 |  v[Any] { v => v }
  |  ^
  |  None of the overloaded alternatives of method v in object abc with types
  |   [T] => abc.Test1
  |   => abc.Test0
  |  match type arguments [Any] and arguments (? => ?)

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Nov 12, 2019

Now it fails with

  |  v[Any] { v => v }
  |  ^^^^^^
  |  method apply in trait Test1 does not take type parameters

this error is clearer and can easily guide to writing v[Any].apply { v => v } instead.

anatoliykmetyuk added a commit that referenced this issue Mar 12, 2020
Fix #4561: Refactor overloading resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants