This commit is contained in:
parent
2d2798c711
commit
48f2ed4967
19
TestSuite/implicitexplicit17.pas
Normal file
19
TestSuite/implicitexplicit17.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
type
|
||||||
|
t1 = class
|
||||||
|
i, j: integer;
|
||||||
|
static function operator implicit<T>(a: array of T): t1; where T: record;
|
||||||
|
begin
|
||||||
|
var obj := new t1;
|
||||||
|
obj.i := integer(object(a[0]));
|
||||||
|
obj.j := integer(object(a[1]));
|
||||||
|
Result := obj;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var a := Arr(1,2);
|
||||||
|
var b: t1 := a;
|
||||||
|
assert(b.i = 1);
|
||||||
|
assert(b.j = 2);
|
||||||
|
end.
|
||||||
26
TestSuite/implicitexplicit18.pas
Normal file
26
TestSuite/implicitexplicit18.pas
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
type
|
||||||
|
TRec = record
|
||||||
|
i: integer;
|
||||||
|
constructor(i: integer);
|
||||||
|
begin
|
||||||
|
self.i := i;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
t1 = class
|
||||||
|
i, j: integer;
|
||||||
|
static function operator implicit<T>(a: array of T): t1; where T: record;
|
||||||
|
begin
|
||||||
|
var obj := new t1;
|
||||||
|
obj.i := TRec(object(a[0])).i;
|
||||||
|
obj.j := TRec(object(a[1])).i;
|
||||||
|
Result := obj;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var a := Arr(new TRec(1),new TRec(2));
|
||||||
|
var b: t1 := a;
|
||||||
|
assert(b.i = 1);
|
||||||
|
assert(b.j = 2);
|
||||||
|
end.
|
||||||
|
|
@ -2387,6 +2387,8 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
{
|
{
|
||||||
if (ctn.IsPointer)
|
if (ctn.IsPointer)
|
||||||
continue;
|
continue;
|
||||||
|
if (ctn.type_special_kind == SemanticTree.type_special_kind.array_kind)
|
||||||
|
ctn = ctn.element_type;
|
||||||
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), false, null);
|
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), false, null);
|
||||||
if (fn == null)
|
if (fn == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2433,6 +2435,8 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
ctn = (ctn as ref_type_node).pointed_type;
|
ctn = (ctn as ref_type_node).pointed_type;
|
||||||
if (ctn.IsPointer)
|
if (ctn.IsPointer)
|
||||||
continue;
|
continue;
|
||||||
|
if (ctn.type_special_kind == SemanticTree.type_special_kind.array_kind)
|
||||||
|
ctn = ctn.element_type;
|
||||||
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), false, null);
|
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), false, null);
|
||||||
if (fn == null)
|
if (fn == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue