Hello,
Please confirm if this is a bug or my mistake.
When i try to overload a assignment operator on a generic class with type restriction i get this error: "Impossible to overload assignment for equal types". However, if i remove the type restriction, the compiles.
==== CODE (compiles) ===
program generic_without_type_restriction;
{$MODE objfpc}
{$MODESWITCH AdvancedRecords}
type
generic Weak<T> = record
private
FValue: T;
public
class operator := (const value: T): specialize Weak<T>; inline;
end;
class operator Weak.:=(const value: T): specialize Weak<T>;
begin
Result.FValue := Value;
end;
begin
end.============
==== CODE (doesn't compiles) ===
program generic_with_type_restriction ;
{$MODE objfpc}
{$MODESWITCH AdvancedRecords}
type
generic Weak<T: IInterface> = record
private
FValue: T;
public
class operator := (const value: T): specialize Weak<T>; inline;
end;
class operator Weak.:=(const value: T): specialize Weak<T>;
begin
Result.FValue := Value;
end;
begin
end.============
Regards
