mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:09:25 +02:00
* allow nil to be assigned to generic types, resolves #34037
* niln is also a constant node git-svn-id: trunk@39934 -
This commit is contained in:
parent
5499533ddc
commit
eea088c5f5
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -16378,6 +16378,7 @@ tests/webtbs/tw33840.pp -text svneol=native#text/pascal
|
|||||||
tests/webtbs/tw33898.pp -text svneol=native#text/pascal
|
tests/webtbs/tw33898.pp -text svneol=native#text/pascal
|
||||||
tests/webtbs/tw3402.pp svneol=native#text/plain
|
tests/webtbs/tw3402.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw34021.pp -text svneol=native#text/pascal
|
tests/webtbs/tw34021.pp -text svneol=native#text/pascal
|
||||||
|
tests/webtbs/tw34037.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3411.pp svneol=native#text/plain
|
tests/webtbs/tw3411.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw34124.pp svneol=native#text/pascal
|
tests/webtbs/tw34124.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3418.pp svneol=native#text/plain
|
tests/webtbs/tw3418.pp svneol=native#text/plain
|
||||||
|
@ -289,7 +289,8 @@ implementation
|
|||||||
if assigned(tstoreddef(def_from).genconstraintdata) or
|
if assigned(tstoreddef(def_from).genconstraintdata) or
|
||||||
assigned(tstoreddef(def_to).genconstraintdata) then
|
assigned(tstoreddef(def_to).genconstraintdata) then
|
||||||
begin
|
begin
|
||||||
if def_from.typ<>def_to.typ then
|
{ constants could get another deftype (e.g. niln) }
|
||||||
|
if (def_from.typ<>def_to.typ) and not(fromtreetype in nodetype_const) then
|
||||||
begin
|
begin
|
||||||
{ not compatible anyway }
|
{ not compatible anyway }
|
||||||
doconv:=tc_not_possible;
|
doconv:=tc_not_possible;
|
||||||
|
@ -197,11 +197,13 @@ interface
|
|||||||
'specializen');
|
'specializen');
|
||||||
|
|
||||||
{ a set containing all const nodes }
|
{ a set containing all const nodes }
|
||||||
nodetype_const = [ordconstn,
|
nodetype_const = [niln,
|
||||||
|
ordconstn,
|
||||||
pointerconstn,
|
pointerconstn,
|
||||||
stringconstn,
|
stringconstn,
|
||||||
guidconstn,
|
guidconstn,
|
||||||
realconstn];
|
realconstn,
|
||||||
|
setconstn];
|
||||||
|
|
||||||
type
|
type
|
||||||
{ all boolean field of ttree are now collected in flags }
|
{ all boolean field of ttree are now collected in flags }
|
||||||
@ -657,7 +659,7 @@ implementation
|
|||||||
|
|
||||||
function is_constnode(p : tnode) : boolean;
|
function is_constnode(p : tnode) : boolean;
|
||||||
begin
|
begin
|
||||||
is_constnode:=(p.nodetype in [niln,ordconstn,realconstn,stringconstn,setconstn,pointerconstn,guidconstn]);
|
is_constnode:=(p.nodetype in nodetype_const);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1939,7 +1939,7 @@ implementation
|
|||||||
not is_objectpascal_helper(tdef(srsymtable.defowner)) then
|
not is_objectpascal_helper(tdef(srsymtable.defowner)) then
|
||||||
internalerror(2013011401);
|
internalerror(2013011401);
|
||||||
{ convert const node to temp node of the extended type }
|
{ convert const node to temp node of the extended type }
|
||||||
if node.nodetype in (nodetype_const+[niln,addrn]) then
|
if node.nodetype in (nodetype_const+[addrn]) then
|
||||||
begin
|
begin
|
||||||
extdef:=tobjectdef(srsymtable.defowner).extendeddef;
|
extdef:=tobjectdef(srsymtable.defowner).extendeddef;
|
||||||
newstatement:=nil;
|
newstatement:=nil;
|
||||||
|
21
tests/webtbs/tw34037.pp
Normal file
21
tests/webtbs/tw34037.pp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
program project1;
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, FGL;
|
||||||
|
|
||||||
|
type
|
||||||
|
TBaseClass = class (TObject)
|
||||||
|
end;
|
||||||
|
|
||||||
|
generic TFPGObjectListEx<T: TBaseClass> = class (specialize TFPGObjectList<T>)
|
||||||
|
function GetItemByID(AID: Integer): T;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFPGObjectListEx.GetItemByID(AID: Integer): T;
|
||||||
|
begin
|
||||||
|
Result:=nil; //T(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user