fcl-passrc: fixed helper in other unit

This commit is contained in:
mattias 2019-07-10 08:28:37 +00:00
parent f3f2341c8a
commit 4e2606fcbe
2 changed files with 39 additions and 1 deletions

View File

@ -16959,7 +16959,7 @@ begin
begin
Entry:=FActiveHelpers[i];
HelperForType:=Entry.HelperForType;
if HelperForType=TypeEl then
if IsSameType(HelperForType,TypeEl,prraNone) then
begin
// add Helper and its ancestors
HelperScope:=TPasClassScope(Entry.Helper.CustomData);

View File

@ -929,6 +929,7 @@ type
Procedure TestTypeHelper_Set;
Procedure TestTypeHelper_Enumerator;
Procedure TestTypeHelper_String;
Procedure TestTypeHelper_StringOtherUnit;
Procedure TestTypeHelper_Boolean;
Procedure TestTypeHelper_Double;
Procedure TestTypeHelper_DoubleAlias;
@ -17421,6 +17422,43 @@ begin
ParseProgram;
end;
procedure TTestResolver.TestTypeHelper_StringOtherUnit;
begin
AddModuleWithIntfImplSrc('unit2.pas',
LinesToStr([
'{$modeswitch typehelpers}',
'type',
' TStringHelper = type helper for String',
' procedure DoIt;',
' end;',
' TCharHelper = type helper for char',
' procedure Fly;',
' end;',
'']),
LinesToStr([
'procedure TStringHelper.DoIt;',
'begin',
' Self[1]:=Self[2];',
'end;',
'procedure TCharHelper.Fly;',
'begin',
' Self:=''c'';',
' Self:=Self;',
'end;',
'']));
StartProgram(true);
Add([
'uses unit2;',
'var s: string;',
'begin',
' ''abc''.DoIt;',
' ''xyz''.DoIt();',
' ''c''.Fly;',
' s.DoIt;',
'']);
ParseProgram;
end;
procedure TTestResolver.TestTypeHelper_Boolean;
begin
StartProgram(false);