* give an error when declaring a class as conforming to a forward-declared

interface: the compiler does not/cannot check whether the class
    implements all required methods in that case, and it moreover leads to
    crashes (mantis #24184). Older versions of Delphi did allow this (and
    don't check whether the interface methods are implemented either), but
    that's simply a (similar) bug in Delphi that has been fixed in XE at
    least
  * fixed compilation of webtbs/tw2727 after this fix

git-svn-id: trunk@24177 -
This commit is contained in:
Jonas Maebe 2013-04-07 12:18:31 +00:00
parent 747342ebb2
commit 3a03586ca9
4 changed files with 32 additions and 7 deletions

1
.gitattributes vendored
View File

@ -12213,6 +12213,7 @@ tests/webtbf/tw24013a.pp svneol=native#text/plain
tests/webtbf/tw24013b.pp svneol=native#text/plain
tests/webtbf/tw2403.pp svneol=native#text/plain
tests/webtbf/tw2414.pp svneol=native#text/plain
tests/webtbf/tw24184.pp svneol=native#text/plain
tests/webtbf/tw2478.pp svneol=native#text/plain
tests/webtbf/tw2562.pp svneol=native#text/plain
tests/webtbf/tw2657.pp svneol=native#text/plain

View File

@ -316,6 +316,11 @@ implementation
Message1(type_e_interface_type_expected,intfdef.typename);
exit;
end;
if ([oo_is_forward,oo_is_formal] * intfdef.objectoptions <> []) then
begin
Message1(parser_e_forward_intf_declaration_must_be_resolved,intfdef.objrealname^);
exit;
end;
if current_objectdef.find_implemented_interface(intfdef)<>nil then
Message1(sym_e_duplicate_id,intfdef.objname^)
else

16
tests/webtbf/tw24184.pp Normal file
View File

@ -0,0 +1,16 @@
{ %fail }
{$mode objfpc}
type
ti = interface;
tc = class(tinterfacedobject, ti)
end;
ti = interface
procedure test;
end;
begin
end.

View File

@ -6,18 +6,21 @@
type
IPersistenceCapable = interface;
TPersistenceCapable = class(TInterfacedObject, IPersistenceCapable)
function nonsense:boolean;
end;
IPersistenceCapable = interface
IPersistenceCapable = interface
['{A7F3DA50-93BF-4EAF-B40C-8F5020E5D890}']
function GetSelf: TObject;
property Self: TObject read GetSelf;
end;
TPersistenceCapable = class(TInterfacedObject, IPersistenceCapable)
function GetSelf: TObject;
function nonsense:boolean;
end;
function TPersistenceCapable.GetSelf: TObject;
begin
result:=nil;
end;
function TPersistenceCapable.nonsense:boolean;
{this works fine if it isn't a method....}