Scala Programming Language
  1. Scala Programming Language
  2. SI-5358

Override error message is misleading and misses an obvious alternative solution.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0
    • Component/s: None
    • Labels:
      None

      Description

      Consider this code:

      trait A { def hi = "A" }
      trait B { def hi = "B" }
      class C extends A with B
      

      It results in the following compiler error message:

      <console>:9: error: overriding method hi in trait A of type => String;
       method hi in trait B of type => String needs `override' modifier
             class C extends A with B
                   ^
      

      The problem is that

      • the solution suggested does not work in most cases, because A and B need to be in some inheritance relationship for it to work:
        scala> trait B { override def hi = "B" }
        <console>:7: error: method hi overrides nothing
               trait B { override def hi = "B" }
                                      ^
        
      • the possibility to use override in C is not mentioned at all:
        class C extends A with B {
          override def hi = "C"
        }
        

      Maybe it is possible to improve this message.

        Activity

        Hide
        Paul Phillips added a comment -

        a6a9684f5b

        Show
        Paul Phillips added a comment - a6a9684f5b

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Simon Ochsenreither
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development