Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.71 KB | None | 0 0
  1.   IFoo = interface
  2.     ['{B1D9563D-8189-41C5-B2C5-AD1D52D83FE7}']
  3.   end;
  4.  
  5.   IEnhancedFoo = interface(IFoo)
  6.     ['{EC74B9B1-1189-4B46-A1EA-D5DF5ABDF55F}']
  7.   end;
  8.  
  9.   IGeneric<T: IFoo> = interface
  10.   end;
  11.  
  12.   ISpecialized = interface(IGeneric<IEnhancedFoo>)
  13.     ['{57691F38-6F9C-4DBB-8A37-6C89147EB036}']
  14.   end;
  15.  
  16.   TWhatever = class
  17.   public
  18.     constructor Create(const AGeneric: IGeneric<IFoo>);
  19.   end;
  20.  
  21.   TImplementation = class(TInterfacedObject, ISpecialized);
  22.  
  23. procedure Main;
  24. var
  25.   intf: ISpecialized;
  26. begin
  27.   intf := TImplementation.Create;
  28.   TWhatever.Create(IGeneric<IFoo>(intf));
  29.   TWhatever.Create(intf); // E2010 Incompatible types: 'Project2.IGeneric<Project2.IFoo>' and 'ISpecialized'
  30. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement