Explorar o código

* Patch from Simone Tacconi to fix alias type getdeclaration. Fixes issue #41109

Michaël Van Canneyt hai 7 meses
pai
achega
b97ace9168
Modificáronse 1 ficheiros con 16 adicións e 1 borrados
  1. 16 1
      packages/fcl-passrc/src/pastree.pp

+ 16 - 1
packages/fcl-passrc/src/pastree.pp

@@ -541,7 +541,7 @@ type
 
   TPasType = class(TPasElement)
   Protected
-    Function FixTypeDecl(aDecl: TPasTreeString) : TPasTreeString;
+    Function FixTypeDecl(aDecl: TPasTreeString) : TPasTreeString; virtual;
   public
     Function SafeName : TPasTreeString; override;
     function ElementTypeName: TPasTreeString; override;
@@ -551,6 +551,8 @@ type
   { TPasAliasType }
 
   TPasAliasType = class(TPasType)
+  protected
+    Function FixTypeDecl(aDecl: TPasTreeString) : TPasTreeString; override;
   public
     procedure FreeChildren(Prepare: boolean); override;
     function ElementTypeName: TPasTreeString; override;
@@ -3372,6 +3374,19 @@ begin
   inherited FreeChildren(Prepare);
 end;
 
+function TPasAliasType.FixTypeDecl(aDecl: TPasTreeString): TPasTreeString;
+
+var
+  PasType : TPasType;
+begin
+  Result:=aDecl;
+  PasType:=TPasTypeAliasType(Self).DestType;
+  Result:='type '+PasType.GetDeclaration(PasType is TPasUnresolvedTypeRef);
+  if (Name<>'') then
+    Result:=SafeName+' = '+Result;
+  ProcessHints(false,Result);
+end;
+
 procedure TPasAliasType.FreeChildren(Prepare: boolean);
 begin
   SubType:=TPasType(FreeChild(SubType,Prepare));