diff --git a/TestSuite/generics25.pas b/TestSuite/generics25.pas new file mode 100644 index 000000000..1c6c256cd --- /dev/null +++ b/TestSuite/generics25.pas @@ -0,0 +1,8 @@ +function f1 := 1; +function f2(params a: array of integer) := 2; + +begin + var a := Arr(f1, f2); + assert(a[0] = 1); + assert(a[1] = 2); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/generics.cs b/TreeConverter/TreeRealization/generics.cs index 736079fc4..6f75a78a4 100644 --- a/TreeConverter/TreeRealization/generics.cs +++ b/TreeConverter/TreeRealization/generics.cs @@ -796,7 +796,12 @@ namespace PascalABCCompiler.TreeRealization //Проверяем фактические, попадающие под params... if (!DeduceInstanceTypes(last_params_type, fact[i].type, deduced, nils)) { - if (alone) + if (alone && fact[i].type is delegated_methods && (fact[i].type as delegated_methods).empty_param_method != null) + { + if (DeduceInstanceTypes(last_params_type, (fact[i].type as delegated_methods).empty_param_method.type, deduced, nils)) + continue; + } + else throw new SimpleSemanticError(loc, "GENERIC_FUNCTION_{0}_CAN_NOT_BE_CALLED_WITH_THESE_PARAMETERS", func.name); return null; }