diff --git a/TestSuite/extensionmethods33.pas b/TestSuite/extensionmethods33.pas new file mode 100644 index 000000000..71edae23f --- /dev/null +++ b/TestSuite/extensionmethods33.pas @@ -0,0 +1,30 @@ +uses System.Windows.Forms; +{$reference System.Windows.Forms.dll} + +var i: integer; + +procedure p1(self: Control); extensionmethod; +begin + Inc(i); +end; + +type + + t1 = abstract class(Panel) + + end; + + t2 = sealed class(t1) + + constructor; + begin + t1(self).p1; + self.p1; + end; + + end; + +begin + var o := new t2; + assert(i = 2); +end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 954ff4fa1..ce0f63bed 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -2041,12 +2041,18 @@ namespace PascalABCCompiler.TreeRealization //sil = (base_type as compiled_generic_instance_type_node).original_generic.find_in_type(name, CurrentScope); return sil; } - - if (sil == null && base_type is compiled_type_node && string.Compare(name, "create", true) != 0) + type_node base_tn = base_type; + if (sil == null && string.Compare(name, "create", true) != 0) { - sil = (base_type as compiled_type_node).find_in_type(name, CurrentScope); + while (sil == null && base_tn != null) + { + if (base_tn is compiled_type_node) + sil = (base_tn as compiled_type_node).find_in_type(name, CurrentScope); + base_tn = base_tn.base_type; + } } + if (this.is_generic_parameter && sil != null) { sil = sil?.Select(x => x.copy()).ToList();