This commit is contained in:
Ivan Bondarev 2021-01-06 20:47:39 +01:00
parent 75073a7c22
commit 22f46b4a01
4 changed files with 27 additions and 3 deletions

View file

@ -0,0 +1,16 @@
type
t0<T> = class
static function operator implicit(o: T): t0<T> := nil;
end;
t1 = class(t0<byte>) end;
procedure p1<T>(q: t0<T>);
begin
assert(q <> nil);
end;
begin
var prog_Q: t1 := new t1;
p1(prog_Q);
end.

View file

@ -1,9 +1,14 @@
type
t1<T> = class
static function operator implicit(o: T): t1<T> := new t1<T>;
o: T;
constructor(o: T);
begin
self.o := o;
end;
static function operator implicit(o: T): t1<T> := new t1<T>(o);
end;
begin
var a: t1<string> := 'abcde';
Assert(a <> nil);
Assert(a.o = 'abcde');
end.

View file

@ -4,11 +4,14 @@
end;
t2<T> = class(t1<T>) end;
var i: integer;
procedure p<T>(r: t1<T>);
begin
r := new t2<T>;
i := 1;
end;
begin
p(new t1<integer>);
assert(i = 1);
end.

View file

@ -1667,7 +1667,7 @@ namespace PascalABCCompiler.TreeConverter
{
if (ptc.second!=null)
{
if (ptc.first.from is null_type_node || ptc.second.from is null_type_node)
if (ptc.first.from is null_type_node || ptc.second.from is null_type_node || ptc.second.from.is_generic_parameter)
continue; // SSM 9/12/20 fix 2363
AddError(new PossibleTwoTypeConversionsInFunctionCall(loc,ptc.first,ptc.second));
}