| [#1154] | project: compiler | priority: low | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Nikolay | Martin | noise | 2007-05-30 13:21:26.0 | |
| subject | [contrib #573] cannot override method with abstract method with narrower return type | |||
| code |
trait A {
def x: Seq[String] = Seq.empty
}
trait B extends A {
override def x: List[String]
}
/*
class C extends AnyRef with B {
override def x: List[String] = Nil
}
*/ |
|||
| what happened | ./test.scala:5: error: error overriding method x;
method x in trait A of type => Seq[String] has incompatible type => Seq[String]
trait B extends A {
^
|
|||
| what expected | compilation without errors | |||
| [back to overview] | ||||
| Nikolay edited on 2007-05-30 13:21:44.0 |
| Martin edited on 2007-05-30 18:20:18.0 |
| The rules of Scala say that x in A overrides x in B, even though B is a subclass of A. Therefore, the error message is correct. |