delphi - [dcc32 fatal error ] : F2084 Internal Error: NC1921

标签 delphi dcc32

我正在尝试在 Delphi Rio 中编译以下代码:

unit untObjectHelper;

interface

uses
   SysUtils;

type
   TObjectHelper = class(TInterfacedObject)
   public
      class procedure Clone(const objOrigem: TObject; const objDestino: TObject);
   end;

implementation

uses
   System.Rtti;

{ TObjectHelper }

class procedure TObjectHelper.Clone(const objOrigem,
   objDestino: TObject);
begin
   if not Assigned(objOrigem) then
      Exit;

   if not Assigned(objDestino) then
      Exit;

   if objOrigem.ClassType <> objDestino.ClassType then
      Exit;

   var contexto := TRttiContext.Create;
   try
      var tipo := contexto.GetType(objOrigem.ClassType);
      var campos := tipo.GetFields();
   finally
      contexto.Free;
   end;
end;

end.

但是出现以下错误:

[dcc32 Fatal Error] untObjectHelper.pas (36): F2084 Internal Error: NC1921

上线:

var fields: = type.GetFields ();

版本:Embarcadero® Delphi 10.3 版本 26.0.33219.4899

我没有找到此错误的引用,有人可以帮助我吗?非常感谢

最佳答案

问题是类型推断,感谢 Rudy Velthuis 的提示

unit untObjectHelper;

interface

uses
   SysUtils;

type
   TObjectHelper = class(TInterfacedObject)
   public
      class procedure Clone(const objOrigem: TObject; const objDestino: TObject);
   end;

implementation

uses
   System.Rtti;

{ TObjectHelper }

class procedure TObjectHelper.Clone(const objOrigem,
   objDestino: TObject);
begin
   if not Assigned(objOrigem) then
      Exit;

   if not Assigned(objDestino) then
      Exit;

   if objOrigem.ClassType <> objDestino.ClassType then
      Exit;

   var contexto := TRttiContext.Create;
   try
      var tipo := contexto.GetType(objOrigem.ClassType);
      var campos: TArray<TRttiField> := tipo.GetFields();
   finally
      contexto.Free;
   end;
end;

end.

关于delphi - [dcc32 fatal error ] : F2084 Internal Error: NC1921,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56005923/

相关文章:

delphi - 如何从 64 位代码调用 32 位 DLL?

delphi - 匿名方法作为函数结果

sql-server - 如何在 SQL Server 中将列的数据类型从整数更改为文本?

delphi - delphi中如何分割字符串

delphi - 我可以向该函数传递哪些参数?

delphi - MSBuild 中的空行而不是任务控制台输出

delphi - 配置MSBuild以调用XE2 dcc32.exe