This commit is contained in:
Ivan Bondarev 2023-07-30 12:07:06 +02:00
parent 6e041d36c9
commit 7f6030c253
3 changed files with 30 additions and 1 deletions

View file

@ -8058,7 +8058,7 @@ namespace PascalABCCompiler.NETGenerator
(ctn2 != null && (ctn2.compiled_type == TypeFactory.ObjectType || ctn2.compiled_type == TypeFactory.EnumType) || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode)
&& (ctn3.is_value_type || ctn3.is_generic_parameter);
if (!box_awaited && (ctn2 != null && ctn2.compiled_type == TypeFactory.ObjectType || tn2.IsInterface) && !(real_parameters[i] is SemanticTree.INullConstantNode)
&& ctn4 != null && ctn4.is_value_type)
&& ctn4 != null && (ctn4.is_value_type || ctn4.is_generic_parameter))
{
box_awaited = true;
use_stn4 = true;

16
TestSuite/generics70.pas Normal file
View file

@ -0,0 +1,16 @@
var i: integer;
procedure p0(o: object);
begin
i := integer(o);
end;
procedure p1<T>(a: T);
begin
p0(object(a));
end;
begin
p1(1);
assert(i = 1);
end.

13
TestSuite/generics71.pas Normal file
View file

@ -0,0 +1,13 @@
var InputList := new List<object>;
procedure GenerateTests<T>(a: array of T);
begin
InputList.Add(object(a[0]));
Print(1);
end;
begin
GenerateTests(Arr('a','b'));
Print(InputList);
assert(char(InputList[0]) = 'a');
end.