Преглед на файлове

* 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 -

Jonas Maebe преди 12 години
родител
ревизия
3a03586ca9
променени са 4 файла, в които са добавени 32 реда и са изтрити 7 реда
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/pdecobj.pas
  3. 16 0
      tests/webtbf/tw24184.pp
  4. 10 7
      tests/webtbs/tw2727.pp

+ 1 - 0
.gitattributes

@@ -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

+ 5 - 0
compiler/pdecobj.pas

@@ -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 - 0
tests/webtbf/tw24184.pp

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

+ 10 - 7
tests/webtbs/tw2727.pp

@@ -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....}