Skip to content

Misleading error message when using extension methods with implicit params with wrong return type #6779

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

minimized code

scala> type F[T]
     | type G[T]
     | type Stuff
     | delegate for Stuff = ???
     |
     | def (x: T) f[T] given Stuff: F[T] = ???
     |
def Stuff_instance: Stuff
def f[T](x: T) given (x$1: Stuff): F[T]

scala> def g[T](x: T): F[G[T]] = x.f given the[Stuff]
1 |def g[T](x: T): F[G[T]] = x.f given the[Stuff]
  |                          ^
  |                          method f does not take more parameters

Used as follows, the error message is fine:

scala> def g[T](x: T): F[G[T]] = x.f
1 |def g[T](x: T): F[G[T]] = x.f
  |                          ^
  |                          Found:    F[T]
  |                          Required: F[G[T]]

scala> def g[T](x: T): F[G[T]] = f(x) given the[Stuff]
1 |def g[T](x: T): F[G[T]] = f(x) given the[Stuff]
  |                          ^^^^^^^^^^^^^^^^^^^^^
  |                          Found:    F[T]
  |                          Required: F[G[T]]

expectation

In def g[T](x: T): F[G[T]] = x.f given the[Stuff], the error message should be:

  |                          Found:    F[T]
  |                          Required: F[G[T]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions