IList.Add gives error from Delphi XE7

Issue #88 closed
Former user created an issue

When calling IList.Add in Delphi XE7 as follows:

// Items : IList<TObject> and o is a TObject;

result := Items.Add(o);

You get an error E2010 Incompatible types. It seems the compiler cannot find the definition of the function defined in IList<T>, only the procedure.

Comments (13)

  1. Stefan Glienke repo owner

    You selected version 1.0 - is that correct? Because the currently released version is 1.1. Are you using that one or the latest develop?

  2. Keith Giddings

    Hi, Stefan, sorry I should have said that it's the latest master from the repository.

    Regards Keith

  3. Stefan Glienke repo owner
    • changed milestone to 1.2
    • changed version to 1.1

    Ok, that would be the 1.1 release version.

    But I cannot reproduce that behavior with either 1.1 nor the latest develop.

  4. Keith Giddings

    Hmm, works for me as well on a small test project, just not in my huge project. I guess it's something to do with the compiler rather than with spring4D.

    It's not a big problem, as I can just call the Add procedure and return count - 1 for the places where I use it.

    Regards Keith

  5. Stefan Glienke repo owner

    Can you tell me the exact error message please? Maybe we are able to find out the reason. It seems that the compiler tries to pick up the method from ICollection<T> which is the ancestor of IList<T> but since its not index based does not return anything from its Add method.

  6. Keith Giddings

    Hi Stefan,

    Here it is:

    [dcc32 Error] OSDsgDesigner.pas(1754): E2010 Incompatible types: 'Integer' and 'procedure, untyped pointer or untyped parameter'

    Interestingly this unit is also part of another (bpl) project, and there it compiles ok.

    Regards Keith

  7. Stefan Glienke repo owner

    Very weird - please make sure that you don't have some old or modified version or DCU files laying around.

    You might strip down the project to a point where it either starts working again (and then undo these steps to isolate the cause of the issue) or to produce an example to reproduce that error.

  8. Log in to comment