diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 65e73c023..e0c9bb159 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -790,24 +790,26 @@ namespace PascalABCCompiler.PCU param_types[i] = FindSpecTypeByHandle(pcu_file.dotnet_names[off].addit[i].offset); } MethodInfo mi = null; - if (pcu_file.dotnet_names[off].name != "op_Explicit") + if (pcu_file.dotnet_names[off].name != "op_Explicit") + { + //mi = t.GetMethod(pcu_file.dotnet_names[off].name, param_types); + List mis = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name); + mi = ChooseMethod(t, mis, param_types); + } + else + { + MethodInfo[] mis = t.GetMethods(); + foreach (MethodInfo mi2 in mis) + if (mi2.Name == "op_Explicit" && mi2.GetParameters()[0].ParameterType == param_types[0].t && mi2.ReturnType == param_types[1].t) mi = mi2; + if (mi == null) { - //mi = t.GetMethod(pcu_file.dotnet_names[off].name, param_types); - List mis = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name); - mi = ChooseMethod(t, mis, param_types); - } - else - { - MethodInfo[] mis = t.GetMethods(); - foreach (MethodInfo mi2 in mis) - if (mi2.Name == "op_Explicit" && mi2.GetParameters()[0].ParameterType == param_types[0].t && mi2.ReturnType == param_types[1].t) mi = mi2; - if (mi == null) - { - List mis2 = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name); - mi = ChooseMethod(t, mis2, param_types); - //mi = t.GetMethod(pcu_file.dotnet_names[off].name, new Type[1] { param_types[0].t }); - } + List mis2 = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name); + mi = ChooseMethod(t, mis2, param_types); + //mi = t.GetMethod(pcu_file.dotnet_names[off].name, new Type[1] { param_types[0].t }); } + } + if (mi == null) + throw new Exception(pcu_file.dotnet_names[off].name+" "+t.FullName); dot_net_cache[off] = mi; return mi; } diff --git a/TestSuite/defaultparams1.pas b/TestSuite/defaultparams1.pas index 8997a5a89..f9ebe41d7 100644 --- a/TestSuite/defaultparams1.pas +++ b/TestSuite/defaultparams1.pas @@ -13,6 +13,21 @@ begin Result := a; end; +function ff(delim: string := ' '): string; +begin + Result := 'abc'; +end; + +procedure tt(str: string); +begin + assert(str = 'abc'); +end; + +procedure tt(i: integer); +begin + raise new Exception; +end; + begin assert(test(2)=3); assert(test(2,4)=4); @@ -24,4 +39,5 @@ var s := 'abcd'; assert(s.test=6); var k := s.test; assert(k = 6); +tt(ff); end. \ No newline at end of file diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index e57763bfb..073193d60 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -2267,9 +2267,9 @@ end; function FormatStr(obj: object): string; begin if (obj.GetType = typeof(char)) or (obj.GetType = typeof(string)) then - Result := '''' + string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', obj) + '''' + Result := '''' + string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', new object[](obj)) + '''' else - Result := string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', obj) + Result := string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', new object[](obj)) end; function TypedSet.ToString: string;