parent
af1b9b85f4
commit
12b365650f
|
|
@ -903,6 +903,25 @@ namespace PascalABCCompiler.PCU
|
||||||
foreach (statement_node st in stmt_list.statements)
|
foreach (statement_node st in stmt_list.statements)
|
||||||
AddIndirectUsedUnitsInStatement(st, ns_dict, interf);
|
AddIndirectUsedUnitsInStatement(st, ns_dict, interf);
|
||||||
}
|
}
|
||||||
|
/*else if (stmt is common_static_method_call)
|
||||||
|
{
|
||||||
|
common_static_method_call csmc = stmt as common_static_method_call;
|
||||||
|
AddIndirectUsedUnitsForType(csmc.common_type, ns_dict, interf);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (stmt is if_node)
|
||||||
|
{
|
||||||
|
if_node node = stmt as if_node;
|
||||||
|
AddIndirectUsedUnitsInStatement(node.condition, ns_dict, interf);
|
||||||
|
}
|
||||||
|
if (stmt is base_function_call)
|
||||||
|
{
|
||||||
|
base_function_call bfc = stmt as base_function_call;
|
||||||
|
foreach (var expr in bfc.parameters)
|
||||||
|
{
|
||||||
|
AddIndirectUsedUnitsInStatement(expr, ns_dict, interf);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
25
TestSuite/implicitexplicit11.pas
Normal file
25
TestSuite/implicitexplicit11.pas
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
var i: integer;
|
||||||
|
type
|
||||||
|
t0 = class end;
|
||||||
|
|
||||||
|
t1 = class
|
||||||
|
|
||||||
|
static function operator implicit<T>(o: T): t1;
|
||||||
|
where T: record;
|
||||||
|
begin
|
||||||
|
i := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
static function operator implicit(o: t0): t1;
|
||||||
|
begin
|
||||||
|
i := 2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure p1(q: t1) := exit;
|
||||||
|
|
||||||
|
begin
|
||||||
|
p1(new t0);
|
||||||
|
assert(i = 2);
|
||||||
|
end.
|
||||||
19
TestSuite/implicitexplicit12.pas
Normal file
19
TestSuite/implicitexplicit12.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
var i: integer;
|
||||||
|
type
|
||||||
|
t1 = class
|
||||||
|
static function operator implicit<T>(o: T): t1;
|
||||||
|
where T: record;
|
||||||
|
begin
|
||||||
|
i := 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
t2<T> = class(t1) end;
|
||||||
|
|
||||||
|
procedure p1(q: t1) := exit;
|
||||||
|
|
||||||
|
begin
|
||||||
|
//Ошибка: Невозможно инстанцировать, так как тип t2<byte> не является размерным
|
||||||
|
p1(new t2<byte>);
|
||||||
|
assert(i = 0);
|
||||||
|
end.
|
||||||
|
|
@ -2321,7 +2321,12 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
{
|
{
|
||||||
if (this.instance_params != null && this.instance_params.Count > 0)
|
if (this.instance_params != null && this.instance_params.Count > 0)
|
||||||
{
|
{
|
||||||
fn = fn.get_instance(this.instance_params, true, null);
|
if (fn.parameters[0].type.is_generic_parameter)
|
||||||
|
fn = fn.get_instance(new List<type_node>() { this }, false, null);
|
||||||
|
else
|
||||||
|
fn = fn.get_instance(this.instance_params, false, null);
|
||||||
|
if (fn == null)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (ctn.instance_params != null && ctn.instance_params.Count > 0)
|
else if (ctn.instance_params != null && ctn.instance_params.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2332,6 +2337,8 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
if (ctn.IsPointer)
|
if (ctn.IsPointer)
|
||||||
continue;
|
continue;
|
||||||
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)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
|
|
@ -2363,9 +2370,11 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
else if (ctn.instance_params != null && ctn.instance_params.Count > 0)
|
else if (ctn.instance_params != null && ctn.instance_params.Count > 0)
|
||||||
{
|
{
|
||||||
if (fn.parameters[0].type.is_generic_parameter)
|
if (fn.parameters[0].type.is_generic_parameter)
|
||||||
fn = fn.get_instance(new List<type_node>() { ctn }, true, null);
|
fn = fn.get_instance(new List<type_node>() { ctn }, false, null);
|
||||||
else
|
else
|
||||||
fn = fn.get_instance(ctn.instance_params, true, null);
|
fn = fn.get_instance(ctn.instance_params, false, null);
|
||||||
|
if (fn == null)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0)
|
else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -2374,6 +2383,8 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
if (ctn.IsPointer)
|
if (ctn.IsPointer)
|
||||||
continue;
|
continue;
|
||||||
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)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue