E07100: defined as default/abstract but an implementation has been provided

Category: E07xxx Full resolution · Reported in phase: SYMBOL_DEFINITION · Classification: ABSTRACT_BUT_BODY_PROVIDED · All error codes

What went wrong

You've marked a method 'abstract' but also provided an implementation body. Abstract methods declare signatures without implementation.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 768 (Why can't an abstract method have a body in EK9?)

How to fix it

  1. Remove body to make truly abstract
  2. Or remove 'abstract' to keep implementation
  3. Choose one: abstract signature OR concrete implementation

Common causes

  • Forgot to remove 'abstract' after adding implementation
  • Confusion about what abstract means
  • Incomplete refactoring

See also

  • E07100: abstract with body (this error)
  • E07110: non-abstract without body
  • E07020: abstract with override

Examples

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

Fails with E07100: defined as default/abstract but an implementation has been provided

#!ek9
defines module error.e07100.bad

  defines class

    Shape as abstract

      //'abstract' says there is no body, yet a value is given
      area() as abstract
        <- rtn as Float: 0.0

Fixed: Remove either 'abstract' or the body

#!ek9
defines module error.e07100.good

  defines class

    Shape as abstract
      //Option 1: keep it abstract, with no body
      area() as abstract
        <- rtn as Float?

      //Option 2: drop 'abstract', and keep the body
      name()
        <- rtn as String: "shape"

Questions and answers

These Q&A entries show E07100 and its fix: