E05040: 'super' for implicit 'Any' base class is not required

Category: E05xxx Explicit type symbol definition · Reported in phase: FULL_RESOLUTION · Classification: SUPER_FOR_ANY_NOT_REQUIRED · All error codes

What went wrong

You're calling super() in a constructor, but this class doesn't explicitly extend another class. While all classes implicitly extend Any, you cannot call super() to the implicit Any parent.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 743 (What are the restrictions on this and super in EK9?)

How to fix it

  1. If this class should extend another: add 'extends ParentClass'
  2. If no parent is needed: remove the super() call entirely
  3. Check if you meant to call a different constructor with this()

Rationale

The implicit Any base class has no constructor logic to call. super() is only meaningful when there's explicit parent initialization.

Common causes

  • Habit from Java where super() is often implicit
  • Forgetting to add 'extends' clause
  • Copy-pasting from a class that does have a parent

See also

  • E05040: super() without explicit parent (this error)
  • E05050: super()/this() not first statement (ordering error)

Examples

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

Fails with E05040: 'super' for implicit 'Any' base class is not required

#!ek9
defines module error.e05040.bad

  defines class

    Greeter
      describe()
        <- rtn as String?
        //Greeter extends nothing explicitly, so its only super is the implicit 'Any'
        rtn: super.greeting()

      greeting()
        <- rtn as String: "hello"

Fixed: With no explicit super, call the method on this (or just by name)

#!ek9
defines module error.e05040.good

  defines class

    Greeter
      describe()
        <- rtn as String: greeting()

      greeting()
        <- rtn as String: "hello"

Questions and answers

These Q&A entries show E05040 and its fix: