diff --git a/packages/fcl-passrc/src/pparser.pp b/packages/fcl-passrc/src/pparser.pp index fade09bc7e..50441c4e51 100644 --- a/packages/fcl-passrc/src/pparser.pp +++ b/packages/fcl-passrc/src/pparser.pp @@ -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; diff --git a/packages/fcl-passrc/tests/tcclasstype.pas b/packages/fcl-passrc/tests/tcclasstype.pas index ea045d625e..56d58b1118 100644 --- a/packages/fcl-passrc/tests/tcclasstype.pas +++ b/packages/fcl-passrc/tests/tcclasstype.pas @@ -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);