mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 02:26:20 +02:00
* fix #40331: for enumeration with holes (that don't have type information) use the binary comparers
+ added test
This commit is contained in:
parent
82857174cc
commit
d5c1533377
@ -2180,7 +2180,8 @@ end;
|
|||||||
|
|
||||||
class function TComparerService.TypeNeedsBinaryMethods<T>: Boolean;
|
class function TComparerService.TypeNeedsBinaryMethods<T>: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := GetTypeKind(T) in TComparerService.UseBinaryMethods;
|
Result := (GetTypeKind(T) in TComparerService.UseBinaryMethods) or
|
||||||
|
((GetTypeKind(T) = tkEnumeration) and not Assigned(TypeInfo(T)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TComparerService.LookupComparer(ATypeInfo: PTypeInfo; ASize: SizeInt): Pointer;
|
class function TComparerService.LookupComparer(ATypeInfo: PTypeInfo; ASize: SizeInt): Pointer;
|
||||||
|
13
tests/webtbs/tw40331.pp
Normal file
13
tests/webtbs/tw40331.pp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
program tw40331;
|
||||||
|
{$mode delphi}
|
||||||
|
uses Generics.Defaults;
|
||||||
|
type
|
||||||
|
SomeEnum = (zero = 0, two = 2);
|
||||||
|
var
|
||||||
|
z: IEqualityComparer<SomeEnum>;
|
||||||
|
begin
|
||||||
|
z:= TEqualityComparer<SomeEnum>.Default;
|
||||||
|
WriteLn('Done');
|
||||||
|
//ReadLn;
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user