This commit is contained in:
parent
75073a7c22
commit
22f46b4a01
16
TestSuite/implicitexplicit6.pas
Normal file
16
TestSuite/implicitexplicit6.pas
Normal 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.
|
||||
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue