Code does not compile with Elements 13.x

This code no longer compiles with latest Elements compiler (13.x)

unit System_;

interface

type
  // Bound to objects
  CObject = public Object;

    // TPropertyFilterFunc = reference to function (const AProperty: String) : Boolean;

  CObjectTypeHelper = public extension class(CObject)
    public
        class function  &From<T>(const Value: T): CObject; overload;
  end;

implementation

class function CObjectTypeHelper.&From<T>(const Value: T): CObject;
begin
  Result := T(Value);
end;

end.

Error: (E62) Type mismatch, cannot assign “T” to “CObject”

This code did compile using Elements 12.X

Hi!

Sorry, I’m unable to reproduce this with latest Elements (13.0.0.3087), what exact version are you using?

13.0.0.3081, the last ‘stable’ release. I’ll update to 3087 and retry the code.

Hello again,

Using 13.0.0.3087 now.

It seems that the error only occurs when you set Delphi compatibility to ‘True’:

I realized that the code should actually read:

class function CObjectTypeHelper.&From(const Value: T): CObject;
begin
Result := CObject(Value);
end;

Now it works…

Thanx, this helps. What platform is this: .NET, Island/Windows, or something else?

Logged as bugs://E27695.

bugs://E27695 was closed as fixed.

Fixed for tomorrow’s build. Our apologies for this regression.