Overloading methods having var parameters

The following code defines three overloaded methods called Test that have var arguments of different types. The code does not compile, with errors as indicated. Why? The methods’ arguments are sufficiently different to distinguish between them.


interface

type
  VarTest = public static class
  public
    method Test(var a, b: Integer); // <-- (I) Previous declaration was here
    method Test(var a, b: Double);   // <-- (X) Duplicate method
    method Test(var a, b: String);  // <-- (X) Duplicate method
  end;

implementation

method VarTest.Test(var a, b: Integer);
begin
  a := 0; b := 0;
end;

method VarTest.Test(var a, b: Double); // <-- (X) Declaration missing
begin
  a := 0; b := 0;
end;

method VarTest.Test(var a, b: String); // <-- (X) Declaration missing
begin
  a := 'a'; b := 'b';
end;

Remove all the vars and the code compiles, but that is not what I need.

Is this Java? On Java due to the lack of actual ref parameter support we have to use a generic class, unfortunately java doesn’t support overloading by generic arguments. We’re looking into some form of mangling for the future but currently this isn’t supported.

Yes, this happens on Java. Actually, I’m trying to develop a cross-platform class library and it is indeed unfortunate that such basic language features do not work across platforms.

We’re planning for some form of mangling to support this for a future version.