From e402243f2d8e0a8eca5d498422a21483dab28565 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Thu, 7 Jan 2021 20:31:51 +0100 Subject: [PATCH] #2311 --- TestSuite/implicitexplicit8.pas | 15 +++++++++++++++ TreeConverter/TreeRealization/types.cs | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 TestSuite/implicitexplicit8.pas diff --git a/TestSuite/implicitexplicit8.pas b/TestSuite/implicitexplicit8.pas new file mode 100644 index 000000000..a88670991 --- /dev/null +++ b/TestSuite/implicitexplicit8.pas @@ -0,0 +1,15 @@ +var o: System.Type; +type + t1 = class + static function operator implicit(val: T): t1; + begin + o := typeof(T); + end; + end; + + t2 = class end; + +begin + var a: t1 := new t2; + assert(o = typeof(t2)); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 87d3efd79..152db4b30 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -2362,7 +2362,10 @@ namespace PascalABCCompiler.TreeRealization } else if (ctn.instance_params != null && ctn.instance_params.Count > 0) { - fn = fn.get_instance(ctn.instance_params, true, null); + if (fn.parameters[0].type.is_generic_parameter) + fn = fn.get_instance(new List() { ctn }, true, null); + else + fn = fn.get_instance(ctn.instance_params, true, null); } else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0) {