Skip to content

Stub code suggestion in missing method error message should use type parameters of present class, not parent trait #13076

Closed
@jphmrst

Description

@jphmrst

Compiler version

3.0.1 (and I've noticed this is earlier versions as well)

Minimized code

trait T[A, B] {
  def f(a: A): B
  def g(a: A, b: B): Unit
}

class C[X, Y] extends T[X, Y] {
}

Output

[info] compiling 1 Scala source to /home/jm/tmp/test/target/scala-3.0.1/classes ...
[error] -- Error: /home/jm/tmp/test/src/main/scala/Main.scala:7:6 ---------------------
[error] 7 |class C[X, Y] extends T[X, Y] {
[error]   |      ^
[error]   |      class C needs to be abstract, since:
[error]   |      it has 2 unimplemented members.
[error]   |      /** As seen from class C, the missing signatures are as follows.
[error]   |       *  For convenience, these are usable as stub implementations.
[error]   |       */
[error]   |        def f(a: A): B = ???
[error]   |        def g(a: A, b: B): Unit = ???
[error] one error found

Expectation

The error is obviously valid, but the suggested code is incorrect: C's type variables are X and Y, not A and B.

Bonus whine: the issue "goes away" if the trait only contains one of the two methods, because when it's just one missing method, there is no suggested stub code. It would be nice to get the stub code in those cases anyway!

Metadata

Metadata

Labels

SpreeSuitable for a future Spreearea:reportingError reporting including formatting, implicit suggestions, etcitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions