Delphi Compatibility issues in 13.0.0.3139

Hi

Our projects (.NET and Java) again fail to compile after changes in the recent stable release.

In 13.0.0.3095, everything worked; in the next stable release, we had issues with Dimension and Java with Seconds, but .NET worked. The new release fails with ~700 duplicated errors. I’ve managed to prepare a test case project that covers all of them.

Test3139.zip (31.9 KB)

Most of the errors are like:

E: Unknown identifier "Create" [Test3139\Program.pas (21)]
E: Ambiguous call to overloaded method "new" [Test3139\Program.pas (59)]
E: No method "AssignedBusyEvent" with matching delegate signature "(_sender: Object; _e: EventArgs)" could be found in type "Program" [Test3139\Program.pas (62)]
E: Cannot get address of value [Test3139\Program.pas (63)]
E: No member "Equals" on type "T" [Test3139\Program.pas (72)](Java)

Now assigning events, delegates, or property callbacks using @ operator doesn’t work and is treated as a Delphi address. Please adjust the latest compiler changes to be compatible with older releases.

We use these flags for projects :

<AllowLegacyWith>True</AllowLegacyWith>
<AllowLegacyOutParams>True</AllowLegacyOutParams>
<AllowLegacyCreate>True</AllowLegacyCreate>
<DelphiCompatibility>True</DelphiCompatibility>
<DelphiDivide>True</DelphiDivide>
<UseLegacyPreprocessor>true</UseLegacyPreprocessor>

Regards

Artur

Hi Artur - my apologies. These will be regressions caused by work I’ve made, and will be code that runs when DelphiCompatibility is true, as in your settings.

I appreciate the repro. Working on it now!

Kind regards,

David

I think we have a fix; build is building now and ill get it to you ASAP when it’s done.

Thank you. I will test it on our big projects and give you feedback asap.

RemObjects Elements with Water - 13.0.0.3140.exe up now.

Almost all errors are fixed. Two units left where I get the error:

(E486) Parameter 1 is "TGIS_VPFExecAddPartEvent", should be "Delegate", in call to Delegate.Remove(source: Delegate; value: Delegate): Delegate
(E406) No overloaded method "Combine" with these parameters on type "Delegate", best matching overload is "Combine(a: Delegate; b: Delegate): Delegate"

Code of a class:

type

TGIS_VPFExecAddPartEvent = procedure of object ;

variable:

FOnAddPart : TGIS_VPFExecAddPartEvent ;

and event:

    /// <event/>
    /// <summary>
    ///   AddPart event. Will be fired when a new part is added to shape.
    /// </summary>
    event    AddPartEvent   : TGIS_VPFExecAddPartEvent
                                             delegate FOnAddPart ;

There are more events and types here, but only those two with procedure of obj without params fails.

Working event :

TGIS_VPFExecAddCoordEvent = procedure(
const _ptg : TGIS_Point3D
) of object ;

FOnAddCoord : TGIS_VPFExecAddCoordEvent ;
    event    AddCoordEvent  : TGIS_VPFExecAddCoordEvent
                                             delegate FOnAddCoord ;

Java compilation works fine.

Thankyou! We’ll check this.

OUut of curiosity, does changing this to

type
  TGIS_VPFExecAddPartEvent = block;

fix the error?

No.

namespace Test3139;

type
  TGIS_BusyEvent = public procedure(
  _sender    : Object ;
  _e         : EventArgs
  ) of object ;

  TGIS_VPFExecAddPartEvent =  procedure of object ;
  TGIS_VPFExecEndShapeEvent = procedure of object ;

  TGIS_VPFExecAddCoordEvent = procedure(
  const _ptg : EventArgs
    ) of object
     ;
  TLayer = class
  private
    FOnBusy : TGIS_BusyEvent ;
    FOnEndShape : TGIS_VPFExecEndShapeEvent ;
    FOnAddPart  : TGIS_VPFExecAddPartEvent  ;
    FOnAddCoord : TGIS_VPFExecAddCoordEvent ;
  public
    constructor Create;
    begin
      inherited;

    end;

    constructor Create(_path : String);
    begin
      Create ;
    end;

    procedure DoBusy(
    const _sender : Object ;
    const _e      : EventArgs
    ) ;
    begin

    end ;

    event BusyEvent    : TGIS_BusyEvent delegate FOnBusy ;

    event    EndShapeEvent  : TGIS_VPFExecEndShapeEvent     delegate FOnEndShape ;
    event    AddPartEvent   : TGIS_VPFExecAddPartEvent delegate FOnAddPart ;
    event    AddCoordEvent  : TGIS_VPFExecAddCoordEvent  delegate FOnAddCoord ;
  end ;


  TLayerClass = class of TLayer;

  Program = class
  public

    class function AssignedBusyEvent  : TGIS_BusyEvent ;
    begin
      var l2 := new TLayer();
      exit(l2.BusyEvent);
    end;

    class method Fetch( busy : TGIS_BusyEvent );
    begin

    end;

    class method Main(aArgs: array of String): Int32;
    begin
      var cls : TLayerClass ;
      var o := cls.new ;
      o.DoBusy(nil, EventArgs.Empty);
      var l1 := new TLayer();
      l1.BusyEvent := Program.AssignedBusyEvent;
      Program.Fetch(@l1.DoBusy);
      l1.BusyEvent := @l1.DoBusy ;
    end;

  end;

extension method TLayer.IndexOf<T>(aitem : T) : Integer ;
begin
  var itm : T ;
  if aitem.Equals(itm) then
    exit(1);
end ;

end.

Double declaration fails:

  TGIS_VPFExecAddPartEvent =  procedure of object ;
  TGIS_VPFExecEndShapeEvent = procedure of object ;

I have an additional question about the Java and introduced units feature. I still have errors in the code like :

function CompareDateTime(
  _d1 : DateTime ;
  _d2 : DateTime
) : Integer ;
var
  res : TimeSpan ;
  milis : Float ;
begin
  res := _d1 - _d2 ;
  milis := res.getTotalMilliSeconds ; <-(E129) Cannot cast from "Milliseconds" to "nullable Float"

  if milis > 0 then
    Result := 1
  else if milis < 0 then
    Result := -1
  else
    Result := 0 ;
end;
function Now : TDateTime ;
begin
{$IF CLR}
Result := TDateTime.Now ;
{$ENDIF}
{$IF JAVA}
Result := DateTime.UtcNow ;

Result := Result.AddSeconds(-Result.OffsetToUTC); <-(E406) No overloaded method "AddSeconds" with these parameters on type "TDateTime", best matching overload is "method AddSeconds(aValue: RemObjects.Oxygene.System.Integer): not nullable DateTime"

java.util.Calendar(Result).setTimeZone(java.util.TimeZone.Default);
{$ENDIF}
end ;

Can you suggest fixes that work with the new compiler?

Thanks.

iirc units auto-convert only between compatible units (e.g., milliseconds to Seconds), but to go to a generic float, it needs a hard as Single/as Double cast.

The idea being to prevent

var x: Double :=MyMillisecondsValue;
var y: Double :=MySecondsValue;
x+Y; // now w ehave mixed uits, w/o any warning

is that RTL2 DateTime? If so, use the scale-less Result.Add(-Result.OffsetToUTC); if the inut value is a Unit. Same problem here: converting a concrete unit to an unscaled integer loses info & could lead to mixing units.

I could be wrong, i’m just going by the standalone snippets w/o full context.

Fixed in new RemObjects Elements with Water - 13.0.0.3140 (B).exe, we hope.

I tested the version, but the previous errors remain:

Test3139_2.zip (31.8 KB)

My bad, i might have sent you the wrong branch. Can you try RemObjects Elements - 13.0.0.3140 (C).exe? (this one doesn’t have Water but it’ll keep the existing 3140 Water you have on upgrade)

Thanks. .NET works now (basic tests). Java compiles but throws exceptions at runtime:

  • when creating a dictionary

An unhandled exception of type 'java.lang.ClassFormatError' occurred in tatukgis.jdk.jar.
Additional information: Duplicate method name "equals" with signature "(Ljava.lang.Object;)Z" in class file ....

  • calling some Swing components

An unhandled exception of type 'java.lang.ClassCastException' occurred in tatukgis.jdk.jar.
Additional information: tatukgis.jdk.pvl.TGIS_PvlActivationWizard cannot be cast to javax.swing.JComponent

I cannot run the test app.

Curious. is this an operator overload?

This is when, I assume, tatukgis.jdk.pvl.TGIS_PvlActivationWizard does implement javax.swing.JComponent?

My gut feeling is we’ll need more concrete test cases for these.

Yes, I must extract some code for the Java test.

Hi Artur,

Thanks for looking for a test!

In the meantime, I’m working on making a repro on this side. Could you please send the complete duplicate-method class name (including any $… suffix), both full stack traces, and the base-class declaration of TGIS_PvlActivationWizard? Those may give some hints.

Thankyou,

David

I sent you a mesage with test case.