E08230: duplicate registration of the same abstract component type in application

Category: E08xxx Pre-IR checks (flow analysis) · Reported in phase: PRE_IR_CHECKS · Classification: DI_DUPLICATE_REGISTRATION · All error codes

What went wrong

The application block has two or more registrations for the same abstract component type. Each abstract type should have exactly one concrete implementation registered.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1334 (Why does EK9 reject two 'register' lines for the same...)

How to fix it

  1. Remove the duplicate registration
  2. If both implementations are needed, use different abstract types

See also

  • E08230: duplicate registration (this error)
  • E08210: missing registration
  • E08190: circular dependency

Examples

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

Fails with E08230: duplicate registration of the same abstract component type in application

#!ek9
defines module error.e08230.bad

  defines component

    AbstractService as abstract
      doWork() as abstract
        <- rtn as Boolean?

      default operator ?

    ServiceImplA is AbstractService
      override doWork()
        <- rtn as Boolean: true

      default operator ?

    ServiceImplB is AbstractService
      override doWork()
        <- rtn as Boolean: false

      default operator ?

  defines application

    dupApp
      register ServiceImplA() as AbstractService
      register ServiceImplB() as AbstractService

Fixed: One registration per abstract component

#!ek9
defines module error.e08230.good

  defines component

    AbstractService as abstract
      doWork() as abstract
        <- rtn as Boolean?
      default operator ?

    ServiceImplA is AbstractService
      override doWork()
        <- rtn as Boolean: true
      default operator ?

    ServiceImplB is AbstractService
      override doWork()
        <- rtn as Boolean: false
      default operator ?

  defines application

    appA
      register ServiceImplA() as AbstractService

    appB
      register ServiceImplB() as AbstractService

Questions and answers

These Q&A entries show E08230 and its fix: