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

Confusing error message when implementing abstract method ("note that X does not match Y") #9138

scabug opened this Issue Feb 7, 2015 · 2 comments


None yet
2 participants
Copy link

scabug commented Feb 7, 2015

trait A
trait B extends A
abstract class C[T <: A] {
  def f(t: T)(s: String): T
class D extends C[B] {
  def f(b: B)(i: Int) = b

Compiling this gives the error message:

[error] E:\prog\jvm\test\a\a.scala:7: class D needs to be abstract, since method
 f in class C of type (t: B)(s: String)B is not defined
[error] (Note that T does not match B)
[error] class D extends C[B] {
[error]       ^
[error] one error found

The real error here is of course that "Int" in the implementation should be "String". However, the message "(Note that T does not match B)" is less than helpful in figuring out this.


This comment has been minimized.

Copy link

scabug commented Feb 7, 2015

Imported From:
Reporter: Knut Arne Vedaa (kavedaa)


This comment has been minimized.

Copy link

martijnhoekstra commented Aug 6, 2017

smaller repro:

trait Base[A] {
  def foo(a: A)(b: Int): Nothing

object Derived extends Base[String] {
  def foo(a: String): Nothing = ???

object creation impossible, since method foo in trait Base of type (a: String)(b: Int)Nothing is not defined
(Note that A does not match String)

reproduces in 2.11.x, 2.12.[0, 3], dotty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment