* "Class of" allowed for fields

This commit is contained in:
Michaël Van Canneyt 2021-11-13 18:14:46 +01:00
parent f4da533440
commit 4820ec0746
2 changed files with 15 additions and 1 deletions

View File

@ -1901,7 +1901,7 @@ Type
Const
// These types are allowed only when full type declarations
FullTypeTokens = [tkGeneric,{tkSpecialize,}tkClass,tkObjCClass,tkInterface,tkObjcProtocol,tkDispInterface,tkType];
FullTypeTokens = [tkGeneric,{tkSpecialize,tkClass,}tkObjCClass,tkInterface,tkObjcProtocol,tkDispInterface,tkType];
// Parsing of these types already takes care of hints
NoHintTokens = [tkProcedure,tkFunction];
InterfaceKindTypes : Array[Boolean] of TPasObjKind = (okInterface,okObjcProtocol);
@ -1951,6 +1951,10 @@ begin
begin
lClassType:=lctClass;
NextToken;
if not (Full or (CurToken=tkOf)) then
ParseExc(nParserTypeNotAllowedHere,SParserTypeNotAllowedHere,[CurtokenText]);
// Parser.CurrentModeswitches:=Parser.CurrentModeswitches+[msClass];
if CurTokenIsIdentifier('Helper') then
begin
// class helper: atype end;

View File

@ -77,6 +77,7 @@ type
procedure TestOneSpecializedClassInterface;
Procedure TestOneField;
Procedure TestOneFieldComment;
Procedure TestOneClassOfField;
procedure TestOneFieldStatic;
Procedure TestOneHelperField;
Procedure TestOneVarField;
@ -675,6 +676,15 @@ begin
AssertVisibility;
end;
procedure TTestClassType.TestOneClassOfField;
begin
AddMember('a : class of MyClass');
ParseClass;
AssertNotNull('Have 1 field',Field1);
AssertMemberName('a');
AssertVisibility;
end;
procedure TTestClassType.TestOneVarField;
begin
StartVisibility(visPublished);