diff --git a/TestSuite/errors/err0001.pas b/TestSuite/errors/err0001.pas index d53923980..029910930 100644 --- a/TestSuite/errors/err0001.pas +++ b/TestSuite/errors/err0001.pas @@ -1,3 +1,3 @@ begin -var a := 1; +var a := 1 end. \ No newline at end of file diff --git a/TestSuite/errors/err0398.pas b/TestSuite/errors/err0398.pas new file mode 100644 index 000000000..50062b512 --- /dev/null +++ b/TestSuite/errors/err0398.pas @@ -0,0 +1,18 @@ +var i: integer; + +type + I1=interface + procedure p1; + end; + C1=class(I1) + + public procedure I1.p1(i: integer); + begin + i := 1; + end; + + end; + +begin + +end. \ No newline at end of file diff --git a/TestSuite/explicitinterface7.pas b/TestSuite/explicitinterface7.pas new file mode 100644 index 000000000..9d68cfcbe --- /dev/null +++ b/TestSuite/explicitinterface7.pas @@ -0,0 +1,27 @@ +var i: integer; + +type + I1=interface + procedure p1; + end; + + C1=class(I1)//Класс C1 не реализует метод p1 интерфейса I1 + + public procedure I1.p1; + begin + i := 1; + end; + public procedure p1; + begin + i := 2; + end; + end; + +begin + var ii: I1 := new C1; + var o := new C1; + ii.p1; + assert(i = 1); + o.p1; + assert(i = 2); +end. \ No newline at end of file diff --git a/TestSuite/explicitinterface8.pas b/TestSuite/explicitinterface8.pas new file mode 100644 index 000000000..c96b361a4 --- /dev/null +++ b/TestSuite/explicitinterface8.pas @@ -0,0 +1,23 @@ +uses System; +var i: integer; + +type + + C1=class(IComparable)//Класс C1 не реализует метод p1 интерфейса I1 + + public function IComparable.CompareTo(item: T): integer; + begin + Result := 1; + end; + public function CompareTo(item: T): integer; + begin + Result := -1; + end; + end; + +begin + var ii: IComparable := new C1; + var o := new C1; + assert(ii.CompareTo(1) = 1); + assert(o.CompareTo(1) = -1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/compilation_context.cs b/TreeConverter/TreeConversion/compilation_context.cs index b6e1e986d..8fa172f38 100644 --- a/TreeConverter/TreeConversion/compilation_context.cs +++ b/TreeConverter/TreeConversion/compilation_context.cs @@ -2758,7 +2758,13 @@ namespace PascalABCCompiler.TreeConverter if (meth is compiled_function_node) tmp_si = cnode.find_in_type((meth as compiled_function_node).cont_type.BaseFullName + "." + meth.name, cnode.Scope); else if (meth is common_method_node) - tmp_si = cnode.find_in_type((meth as common_method_node).cont_type.BaseFullName + "." + meth.name, cnode.Scope); + { + string base_type_name = (meth as common_method_node).cont_type.BaseFullName; + if (base_type_name != null && (meth as common_method_node).cont_type.original_generic != null && base_type_name.IndexOf('<') != -1) + base_type_name = (meth as common_method_node).cont_type.original_generic.BaseFullName; + tmp_si = cnode.find_in_type(base_type_name + "." + meth.name, cnode.Scope); + } + if (tmp_si != null) { /*Зачем это?