E50080: cannot make a call on an abstract function/type directly

Category: E50xxx Common errors · Reported in phase: FULL_RESOLUTION · Classification: CANNOT_CALL_ABSTRACT_TYPE · All error codes

What went wrong

You're trying to directly instantiate an abstract type or function. Abstract types define contracts without implementation - you must extend them.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 821 (Why can't I construct an abstract type directly in EK9?)
  • ek9 -q 831 (Why can't I use an abstract function as a return type dir...)
  • ek9 -q 103 (What are abstract classes and methods in EK9?)
  • ek9 -q 111 (What are components in EK9?)
  • ek9 -q 114 (How do aspects work with components for AOP?)

[BUILT-IN ABSTRACT TYPES]

  • SignalHandler: `-> signal as String <- result as Integer?`
  • TCPHandler: `-> input as StringInput, output as StringOutput`

How to fix it

  1. Create concrete implementation extending abstract type
  2. Use built-in concrete subtypes where available
  3. Use dynamic function syntax: `() is AbstractType as function`

Common causes

  • Direct call to abstract function
  • Constructor call on abstract class
  • Trying to instantiate built-in abstract types

See also

  • E50080: abstract type instantiation (this error)
  • E50070: abstract function in concrete context
  • E10030: parameterized abstract generic type

Examples

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

Fails with E50080: cannot make a call on an abstract function/type directly

#!ek9
defines module error.e50080.bad

  defines class

    Shape as abstract
      area() as abstract
        <- rtn as Float?

  defines function

    demo()
      <- rtn as Float?
      shape <- Shape()
      rtn: shape.area()

Fixed: Construct a concrete subtype

#!ek9
defines module error.e50080.good

  defines class

    Shape as abstract
      area() as abstract
        <- rtn as Float?

    Circle extends Shape
      radius as Float: 5.0

      override area()
        <- rtn as Float: radius * radius

      default operator ?

  defines function

    demo()
      <- rtn as Float?
      shape as Shape: Circle()
      rtn: shape.area()

Questions and answers

These Q&A entries show E50080 and its fix: