From c4576faff0690e6ccf9ed8d012d4b76fecf9691e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 27 Sep 2020 18:07:00 +0200 Subject: [PATCH] bug fix #2303 --- TestSuite/implicitexplicit5.pas | 14 ++++++++++++++ .../TreeConversion/syntax_tree_visitor.cs | 1 + TreeConverter/TreeRealization/types.cs | 8 ++++++++ 3 files changed, 23 insertions(+) create mode 100644 TestSuite/implicitexplicit5.pas diff --git a/TestSuite/implicitexplicit5.pas b/TestSuite/implicitexplicit5.pas new file mode 100644 index 000000000..c57ad7afa --- /dev/null +++ b/TestSuite/implicitexplicit5.pas @@ -0,0 +1,14 @@ +type + t1 = class + i: object; + constructor(i: object); + begin + self.i := i; + end; + static function operator implicit(val: T): t1 := new t1(val); + end; + +begin + var a: t1 := 5; + assert(integer(a.i) = 5); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index c8c015c0a..a19aab69e 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -14882,6 +14882,7 @@ namespace PascalABCCompiler.TreeConverter if (expr is common_constructor_call_as_constant) return expr as common_constructor_call_as_constant; convertion_data_and_alghoritms.check_convert_type(expr,tn,expr.location); + return constant; //AddError(new CanNotConvertTypes(expr,expr.type,tn,expr.location)); //throw new NotSupportedError(loc); } diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index dc548c082..79dc48059 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -2327,6 +2327,10 @@ namespace PascalABCCompiler.TreeRealization { fn = fn.get_instance(ctn.instance_params, true, null); } + else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0) + { + fn = fn.get_instance(new List(new type_node[] { ctn }), true, null); + } } return fn; } @@ -2358,6 +2362,10 @@ namespace PascalABCCompiler.TreeRealization { fn = fn.get_instance(ctn.instance_params, true, null); } + else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0) + { + fn = fn.get_instance(new List(new type_node[] { ctn }), true, null); + } } return fn; }