From 0d19f9073f3545eb85a924c4eedc4924f71df6f0 Mon Sep 17 00:00:00 2001 From: Ivan Bondarev Date: Tue, 19 Oct 2021 21:05:16 +0200 Subject: [PATCH] #2543 --- Compiler/PCU/PCUWriter.cs | 7 +++++++ TestSuite/units/u_methodcall1.pas | 20 ++++++++++++++++++++ TestSuite/units/u_methodcall2.pas | 8 ++++++++ TestSuite/units/u_methodcall3.pas | 10 ++++++++++ TestSuite/usesunits/use_methodcall1.pas | 5 +++++ 5 files changed, 50 insertions(+) create mode 100644 TestSuite/units/u_methodcall1.pas create mode 100644 TestSuite/units/u_methodcall2.pas create mode 100644 TestSuite/units/u_methodcall3.pas create mode 100644 TestSuite/usesunits/use_methodcall1.pas diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index 390d14f80..2b0fd2bf3 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -877,6 +877,8 @@ namespace PascalABCCompiler.PCU if (tn is common_type_node) { common_namespace_node comp_cnn = (tn as common_type_node).comprehensive_namespace; + if (tn is common_generic_instance_type_node) + comp_cnn = (tn as common_generic_instance_type_node).common_original_generic.comprehensive_namespace; if (comp_cnn != null && !ns_dict.ContainsKey(comp_cnn) && unit.SemanticTree != comp_cnn.cont_unit) { var path = Compiler.GetUnitPath(unit, compiler.UnitsSortedList.Find(u => u.SemanticTree == comp_cnn.cont_unit)); @@ -912,6 +914,11 @@ namespace PascalABCCompiler.PCU common_static_method_call csmc = stmt as common_static_method_call; AddIndirectUsedUnitsForType(csmc.common_type, ns_dict, interf); } + else if (stmt is common_method_call) + { + common_method_call cmc = stmt as common_method_call; + AddIndirectUsedUnitsForType(cmc.function_node.cont_type, ns_dict, interf); + } else if (stmt is if_node) { if_node node = stmt as if_node; diff --git a/TestSuite/units/u_methodcall1.pas b/TestSuite/units/u_methodcall1.pas new file mode 100644 index 000000000..347af61fc --- /dev/null +++ b/TestSuite/units/u_methodcall1.pas @@ -0,0 +1,20 @@ +unit u_methodcall1; + +uses u_methodcall2; + +var + i: integer; + +procedure p1; +begin + var a: t2 := new t2; + var p := procedure-> + begin + a.p1; + Inc(i); + end; + p; +end; + +begin +end. \ No newline at end of file diff --git a/TestSuite/units/u_methodcall2.pas b/TestSuite/units/u_methodcall2.pas new file mode 100644 index 000000000..6566e9967 --- /dev/null +++ b/TestSuite/units/u_methodcall2.pas @@ -0,0 +1,8 @@ +unit u_methodcall2; + +uses u_methodcall3; + +type + t2 = class(t1) end; + +end. \ No newline at end of file diff --git a/TestSuite/units/u_methodcall3.pas b/TestSuite/units/u_methodcall3.pas new file mode 100644 index 000000000..9a6f6ec74 --- /dev/null +++ b/TestSuite/units/u_methodcall3.pas @@ -0,0 +1,10 @@ +unit u_methodcall3; + +type + t1 = class + + procedure p1 := exit; + + end; + +end. \ No newline at end of file diff --git a/TestSuite/usesunits/use_methodcall1.pas b/TestSuite/usesunits/use_methodcall1.pas new file mode 100644 index 000000000..91055c542 --- /dev/null +++ b/TestSuite/usesunits/use_methodcall1.pas @@ -0,0 +1,5 @@ +uses u_methodcall1; +begin + p1; + assert(i = 1); +end. \ No newline at end of file