diff --git a/compiler/packages/fcl-passrc/src/pasuseanalyzer.pas b/compiler/packages/fcl-passrc/src/pasuseanalyzer.pas index 7b31308..5faf8d4 100644 --- a/compiler/packages/fcl-passrc/src/pasuseanalyzer.pas +++ b/compiler/packages/fcl-passrc/src/pasuseanalyzer.pas @@ -3159,15 +3159,10 @@ begin end; function TPasAnalyzer.IsSpecializedGenericType(El: TPasElement): boolean; -var - GenScope: TPasGenericScope; begin - if El is TPasGenericType then - begin - GenScope:=El.CustomData as TPasGenericScope; - if (GenScope<>nil) and (GenScope.SpecializedFromItem<>nil) then - exit(true); - end; + if (El is TPasGenericType) and (El.CustomData is TPasGenericScope) + and (TPasGenericScope(El.CustomData).SpecializedFromItem<>nil) then + exit(true); Result:=false; end; diff --git a/compiler/packages/fcl-passrc/tests/tcuseanalyzer.pas b/compiler/packages/fcl-passrc/tests/tcuseanalyzer.pas index 2ba2095..cbbe4a9 100644 --- a/compiler/packages/fcl-passrc/tests/tcuseanalyzer.pas +++ b/compiler/packages/fcl-passrc/tests/tcuseanalyzer.pas @@ -78,6 +78,7 @@ type procedure TestM_Class; procedure TestM_ClassForward; procedure TestM_Class_Property; + procedure TestM_ClassForward_Generic; procedure TestM_Class_PropertyProtected; procedure TestM_Class_PropertyOverride; procedure TestM_Class_PropertyOverride2; @@ -1153,6 +1154,30 @@ begin AnalyzeProgram; end; +procedure TTestUseAnalyzer.TestM_ClassForward_Generic; +begin + StartUnit(false); + Add([ + '{$mode delphi}', + 'interface', + 'type', + ' {tobject_used}TObject = class', + ' end;', + ' TBird = class;', + ' TAnt = class end;', + ' TBird = class end;', + 'implementation', + 'type', + ' TBird2 = class;', + ' TAnt2 = class end;', + ' TBird2 = class end;', + 'var Bird2: TBird2;', + 'begin', + ' if Bird2=nil then;', + '']); + AnalyzeUnit; +end; + procedure TTestUseAnalyzer.TestM_Class_PropertyProtected; begin StartUnit(false);