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

Return type of method not checked when overriding methods from self type in trait #9736

Open
scabug opened this issue Apr 6, 2016 · 1 comment
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Apr 6, 2016

When overriding a method from the self type of a trait the return type is not checked so this compiles:

trait A {
    def a: Int
}
trait B { self: A =>
    override def a: String = "Well this should not compile"
} 

The compile error happens when B is used:

scala> class C extends A with B
<console>:9: error: overriding method a in trait A of type => Int;
 method a in trait B of type => String has incompatible type
       class C extends A with B
             ^

The compile error should already happen when defining B as the method overrides nothing.

@scabug
Copy link
Author

scabug commented Apr 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9736?orig=1
Reporter: Merlin Göttlinger (mgttlinger)
Affected Versions: 2.11.6, 2.11.8

@scabug scabug added this to the Backlog 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

2 participants