fcl-passrc: resolver: fixed error when accessing element of forward class

This commit is contained in:
mattias 2022-05-27 11:45:24 +02:00
parent 0c9b622a74
commit 653303274f
2 changed files with 21 additions and 0 deletions

View File

@ -21396,6 +21396,9 @@ begin
and not IsFullySpecialized(TPasGenericType(CurScopeEl)) then
RaiseMsg(20200217131215,nGenericsWithoutSpecializationAsType,
sGenericsWithoutSpecializationAsType,['reference'],ErrorEl);
if (CurScopeEl is TPasClassType) and TPasClassType(CurScopeEl).IsForward then
RaiseMsg(20220527113900,nIdentifierNotFound,
sIdentifierNotFound,[CurName],ErrorEl);
CurScope:=PushDotScope(TPasType(CurScopeEl));
if CurScope=nil then
RaiseMsg(20190122122529,nIllegalQualifierAfter,sIllegalQualifierAfter,

View File

@ -562,6 +562,7 @@ type
Procedure TestClassForwardDelphiFail;
Procedure TestClassForwardObjFPCProgram;
Procedure TestClassForwardObjFPCUnit;
Procedure TestClassForwardNestedTypeFail;
Procedure TestClass_Method;
Procedure TestClass_ConstructorMissingDotFail;
Procedure TestClass_MethodImplDuplicateFail;
@ -9519,6 +9520,23 @@ begin
ParseUnit;
end;
procedure TTestResolver.TestClassForwardNestedTypeFail;
begin
StartProgram(false);
Add([
'type',
' TObject = class',
' end;',
' TBird = class;',
' TProc = procedure(a: TBird.TEnum);',
' TBird = class',
' type TEnum = (red,blue);',
' end;',
'begin',
'']);
CheckResolverException('identifier not found "TEnum"',nIdentifierNotFound);
end;
procedure TTestResolver.TestClass_Method;
begin
StartProgram(false);