mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 07:08:56 +02:00
fcl-passrc: forbid type reference to TGeneric.Something
git-svn-id: trunk@44203 -
This commit is contained in:
parent
40a975b803
commit
f05b51d7d8
@ -20560,6 +20560,10 @@ begin
|
||||
NeedPop:=true;
|
||||
if CurScopeEl is TPasType then
|
||||
begin
|
||||
if (CurScopeEl is TPasGenericType)
|
||||
and not IsFullySpecialized(TPasGenericType(CurScopeEl)) then
|
||||
RaiseMsg(20200217131215,nGenericsWithoutSpecializationAsType,
|
||||
sGenericsWithoutSpecializationAsType,['reference'],ErrorEl);
|
||||
CurScope:=PushDotScope(TPasType(CurScopeEl));
|
||||
if CurScope=nil then
|
||||
RaiseMsg(20190122122529,nIllegalQualifierAfter,sIllegalQualifierAfter,
|
||||
|
@ -88,6 +88,7 @@ type
|
||||
procedure TestGen_Class_Self;
|
||||
procedure TestGen_Class_MemberTypeConstructor;
|
||||
procedure TestGen_Class_AliasMemberType;
|
||||
procedure TestGen_Class_AccessGenericMemberTypeFail;
|
||||
procedure TestGen_Class_ReferenceTo; // ToDo
|
||||
procedure TestGen_Class_List;
|
||||
// ToDo: different modeswitches at parse time and specialize time
|
||||
@ -1416,6 +1417,25 @@ begin
|
||||
ParseProgram;
|
||||
end;
|
||||
|
||||
procedure TTestResolveGenerics.TestGen_Class_AccessGenericMemberTypeFail;
|
||||
begin
|
||||
StartProgram(false);
|
||||
Add([
|
||||
'{$mode objfpc}',
|
||||
'type',
|
||||
' TObject = class end;',
|
||||
'',
|
||||
' generic TBird<T> = class',
|
||||
' public type',
|
||||
' TRun = reference to function (aValue : T) : T;',
|
||||
' end;',
|
||||
' TBirdRun = TBird.TRun;',
|
||||
'begin',
|
||||
'']);
|
||||
CheckResolverException('Generics without specialization cannot be used as a type for a reference',
|
||||
nGenericsWithoutSpecializationAsType);
|
||||
end;
|
||||
|
||||
procedure TTestResolveGenerics.TestGen_Class_ReferenceTo;
|
||||
begin
|
||||
exit;
|
||||
|
Loading…
Reference in New Issue
Block a user