fix #1407
This commit is contained in:
parent
d32f637e09
commit
74b29425e7
8
TestSuite/CompilationSamples/delegates12.pas
Normal file
8
TestSuite/CompilationSamples/delegates12.pas
Normal 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.
|
||||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue