fork download
  1. trait Token[ValueType] {
  2. def value: ValueType
  3.  
  4. def stringValue: String = value.toString
  5.  
  6. override def toString: String = stringValue
  7. }
  8.  
  9. // ----
  10.  
  11. trait BaseToken[ValueType] extends Token[ValueType]
  12.  
  13. // ----
  14.  
  15. abstract sealed case class Keyword(name: String) extends BaseToken[Keyword] {
  16. override def value: Keyword = this
  17.  
  18. override def toString = name
  19. }
  20.  
  21. case object AND extends Keyword("AND")
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:21: error: case object AND has case ancestor Keyword, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
case object AND extends Keyword("AND")
            ^
one error found
spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty