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 mismatch error when implementing method with return type dependent on member of parameterized type #9701

Closed
scabug opened this issue Mar 12, 2016 · 3 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 12, 2016

The following code:

trait A[X] {
  type M
}
class B[X]
trait C {
  def f[X](a: A[X]): B[a.M]
}
class D extends C {
  override def f[X](a: A[X]) = new B[a.M]
}

fails to compile, with the confusing error message:

[ERROR] C:\Users\Michael\workspace\paperdoll\src\main\scala\com\github\m50d\paperdoll\effect\Eff.scala:9: error: type mismatch;
[ERROR]  found   : B[a.M]
[ERROR]  required: B[a.M]
[ERROR]   override def f[X](a: A[X]) = new B[a.M]

As far as I can see this code should compile? If not then the error should be clearer.

@scabug
Copy link
Author

scabug commented Mar 12, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9701?orig=1
Reporter: Michael Donaghy (lmm)
Affected Versions: 2.11.8

@scabug
Copy link
Author

scabug commented Mar 13, 2016

Michael Donaghy (lmm) said:
Paul Phillips pointed out that one can work around this by specifying the return type of the overriding method explicitly.

@scabug
Copy link
Author

scabug commented Sep 29, 2016

@SethTisue said:
compiles in 2.12.0-RC1

@scabug scabug closed this as completed Sep 29, 2016
@scabug scabug added the typer label Apr 7, 2017
@scabug scabug added this to the 2.12.0-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant