scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

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

Open scabug opened 8 years ago

scabug commented 8 years ago

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 commented 8 years ago

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