E07140: all abstract methods/operators must be implemented

Category: E07xxx Full resolution · Reported in phase: FULL_RESOLUTION · Classification: DYNAMIC_CLASS_MUST_IMPLEMENT_ABSTRACTS · All error codes

What went wrong

You're creating a dynamic class that extends an abstract type, but you haven't implemented all required abstract methods.

Worked examples

Compilable examples demonstrating this error and the correct fix:

How to fix it

  1. Implement all abstract methods in dynamic class
  2. Check parent class for all abstract methods
  3. Each abstract method needs override in dynamic class

Common causes

  • Missing method implementations in dynamic class
  • Not aware of all abstract methods from parent
  • Incomplete dynamic class definition

See also

  • E07140: dynamic class missing abstract implementations (this error)
  • E07130: non-abstract type with abstract methods

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E07140: all abstract methods/operators must be implemented

#!ek9
defines module error.e07140.bad

  defines trait
    Processor
      process() as abstract
        -> input as String
        <- output as String?

      validate() as abstract
        -> input as String
        <- valid as Boolean?

  defines program

    ProcessOrder()
      stdout <- Stdout()

      //validate() is not implemented
      processor <- () with trait of Processor as class
        override process()
          -> input as String
          <- output as String: "processed: " + input

      stdout.println(processor.process("order"))

Fixed: Implement every abstract method in the dynamic class

#!ek9
defines module error.e07140.good

  defines trait
    Processor
      process() as abstract
        -> input as String
        <- output as String?

      validate() as abstract
        -> input as String
        <- valid as Boolean?

  defines program

    ProcessOrder()
      stdout <- Stdout()

      processor <- () with trait of Processor as class
        override process()
          -> input as String
          <- output as String: "processed: " + input

        override validate()
          -> input as String
          <- valid as Boolean: input?

      if processor.validate("order")
        stdout.println(processor.process("order"))

Questions and answers

These Q&A entries show E07140 and its fix: