Delphi Error – E2205 Interface type required

Delphi Compiler Error

E2205 Interface type required

Reason for the Error & Solution

A type, which is an interface, was expected but not found. A common cause of this error is the specification of a user-defined type that has not been declared as an interface type.

program Produce;
  type
    Name = string;

    MyObject = class
    end;

    MyInterface = interface(MyObject)
    end;

    Base = class(TObject, Name)
    end;

begin
end.

In this example, the type ‘Base’ is erroneously declared since ‘Name’ is not declared as an interface type. Likewise, ‘MyInterface’ is incorrectly declared because its ancestor interface was not declared as such.

program Solve;
  type
    BaseInterface = interface
    end;

    MyInterface = interface(BaseInterface)
    end;

    Base = class(TObject, MyInterface)
    end;

begin
end.

The best solution when encountering this error is to reexamine the source code to determine what was really intended. If a class is to implement an interface, it must first be explicitly derived from a base type such as TObject. When extended, interfaces can only have a single interface as its ancestor.

In the example above, the interface is properly derived from another interface and the object definition correctly specifies a base so that interfaces can be specified.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...