diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index ef87071ac..1dc21a210 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -903,6 +903,25 @@ namespace PascalABCCompiler.PCU foreach (statement_node st in stmt_list.statements) 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); + } + }*/ } diff --git a/TestSuite/implicitexplicit11.pas b/TestSuite/implicitexplicit11.pas new file mode 100644 index 000000000..31600ced2 --- /dev/null +++ b/TestSuite/implicitexplicit11.pas @@ -0,0 +1,25 @@ +var i: integer; +type + t0 = class end; + + t1 = class + + static function operator implicit(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. \ No newline at end of file diff --git a/TestSuite/implicitexplicit12.pas b/TestSuite/implicitexplicit12.pas new file mode 100644 index 000000000..b2a7b9445 --- /dev/null +++ b/TestSuite/implicitexplicit12.pas @@ -0,0 +1,19 @@ +var i: integer; +type + t1 = class + static function operator implicit(o: T): t1; + where T: record; + begin + i := 1; + end; + end; + + t2 = class(t1) end; + +procedure p1(q: t1) := exit; + +begin + //Ошибка: Невозможно инстанцировать, так как тип t2 не является размерным + p1(new t2); + assert(i = 0); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 7e7b91fbd..72f10653a 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -2321,7 +2321,12 @@ namespace PascalABCCompiler.TreeRealization { 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() { 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) { @@ -2332,6 +2337,8 @@ namespace PascalABCCompiler.TreeRealization if (ctn.IsPointer) continue; fn = fn.get_instance(new List(new type_node[] { ctn }), false, null); + if (fn == null) + continue; } } return fn; @@ -2363,9 +2370,11 @@ namespace PascalABCCompiler.TreeRealization else if (ctn.instance_params != null && ctn.instance_params.Count > 0) { if (fn.parameters[0].type.is_generic_parameter) - fn = fn.get_instance(new List() { ctn }, true, null); + fn = fn.get_instance(new List() { ctn }, false, null); 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) { @@ -2374,6 +2383,8 @@ namespace PascalABCCompiler.TreeRealization if (ctn.IsPointer) continue; fn = fn.get_instance(new List(new type_node[] { ctn }), false, null); + if (fn == null) + continue; } } return fn;