diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index a9f8eb417..36e7ce754 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -903,6 +903,7 @@ namespace PascalABCCompiler.PCU 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.UnitsTopologicallySortedList.Find(u => u.SemanticTree == comp_cnn.cont_unit)); @@ -916,6 +917,11 @@ namespace PascalABCCompiler.PCU } if (tn.base_type is common_type_node) AddIndirectUsedUnitsForType(tn.base_type, ns_dict, interf); + if (tn is common_generic_instance_type_node) + { + foreach (type_node param_tn in (tn as common_generic_instance_type_node).instance_params) + AddIndirectUsedUnitsForType(param_tn, ns_dict, interf); + } } } diff --git a/TestSuite/units/u_indirect1.pas b/TestSuite/units/u_indirect1.pas new file mode 100644 index 000000000..84ce9327d --- /dev/null +++ b/TestSuite/units/u_indirect1.pas @@ -0,0 +1,10 @@ +unit u_indirect1; + +uses u_indirect2; + +procedure p1(o: t1) := exit; + +begin + p1(new t2); + p1(new t3); +end. \ No newline at end of file diff --git a/TestSuite/units/u_indirect2.pas b/TestSuite/units/u_indirect2.pas new file mode 100644 index 000000000..bfb86ebd8 --- /dev/null +++ b/TestSuite/units/u_indirect2.pas @@ -0,0 +1,10 @@ +unit u_indirect2; + +uses u_indirect3; + +type + t1 = class end; + t2 = class(t1) end; + t3 = t1; + +end. \ No newline at end of file diff --git a/TestSuite/units/u_indirect3.pas b/TestSuite/units/u_indirect3.pas new file mode 100644 index 000000000..732d43f45 --- /dev/null +++ b/TestSuite/units/u_indirect3.pas @@ -0,0 +1,6 @@ +unit u_indirect3; + +type + t_err = class end; + +end. \ No newline at end of file diff --git a/TestSuite/usesunits/use_indirect1.pas b/TestSuite/usesunits/use_indirect1.pas new file mode 100644 index 000000000..c4fee1309 --- /dev/null +++ b/TestSuite/usesunits/use_indirect1.pas @@ -0,0 +1,4 @@ +uses u_indirect1; +begin + +end. \ No newline at end of file