This commit is contained in:
Бондарев Иван 2019-01-06 11:07:07 +01:00
parent d32f637e09
commit 74b29425e7
3 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,8 @@
function f(x: real) := x*2;
function g(x: real) := x+1;
begin
var fg: real -> real := f*g;
assert(abs(fg(1)-4) < 0.00000001);
end.

View file

@ -515,6 +515,16 @@ namespace PascalABCCompiler.NetHelper
mths = new List<MethodInfo>();
type_extensions.Add(tmp, mths);
}
if ((tmp.BaseType == DelegateType || tmp.BaseType == MulticastDelegateType))
{
List<MethodInfo> mths3 = null;
if (!type_extensions.TryGetValue(DelegateType, out mths3))
{
mths3 = new List<MethodInfo>();
type_extensions.Add(DelegateType, mths3);
}
mths3.Add(mi);
}
mths.Add(mi);
if (tmp.IsArray && !generic_array_type_extensions.TryGetValue(tmp.GetArrayRank(), out mths2))
{

View file

@ -1137,9 +1137,18 @@ namespace PascalABCCompiler.TreeRealization
{
delegate_internal_interface dii = formal_type.get_internal_interface(internal_interface_kind.delegate_interface) as delegate_internal_interface;
delegated_methods dm = fact_type as delegated_methods;
function_node fact_func = null;
if (dm != null && dm.proper_methods.Count == 1)
fact_func = dm.proper_methods[0].simple_function_node;
else if (fact_type.IsDelegate)
{
var sil = fact_type.find_in_type("Invoke");
if (sil != null && sil.Count > 0)
fact_func = sil[0].sym_info as function_node;
}
if (fact_func != null)
{
function_node fact_func = dm.proper_methods[0].simple_function_node;
if (fact_func.parameters.Count != dii.parameters.Count)
{
goto eq_cmp;