diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index be37fc834b..e52777ab1c 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -2137,7 +2137,19 @@ implementation begin if assigned(getprocvardef) and equal_defs(p1.resultdef,getprocvardef) then - again:=false + begin + { classes can define now types so we've to allow + type casts with these nested types as well } + if (p1.nodetype=typen) and + try_to_consume(_LKLAMMER) then + begin + p1:=comp_expr(true); + consume(_RKLAMMER); + p1:=ctypeconvnode.create_explicit(p1,p1.resultdef); + end + else + again:=false + end else begin if try_to_consume(_LKLAMMER) then diff --git a/tests/test/tgeneric10.pp b/tests/test/tgeneric10.pp index ed22070795..26c89c2ff1 100644 --- a/tests/test/tgeneric10.pp +++ b/tests/test/tgeneric10.pp @@ -4,7 +4,7 @@ type generic TList<_T>=class(TObject) type public TCompareFunc = function(const Item1, Item2: _T): Integer; - var public + var public data : _T; compare : TCompareFunc; procedure Add(item: _T); @@ -17,7 +17,7 @@ begin halt(1); end; -function CompareInt(Item1, Item2: Integer): Integer; +function CompareInt(const Item1, Item2: Integer): Integer; begin Result := Item2 - Item1; end; @@ -33,4 +33,5 @@ begin ilist := TMyIntList.Create; ilist.compare := ilist.TCompareFunc(@CompareInt); ilist.add(someInt); + writeln('ok'); end.