This commit is contained in:
parent
e0b99afa27
commit
078d140c21
|
|
@ -1435,6 +1435,41 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool has_meth_contrains = false;
|
||||||
|
foreach (var meth in ctn.methods)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (meth.generic_params != null && meth.generic_params.Count > 0)
|
||||||
|
foreach (var gp in meth.generic_params)
|
||||||
|
{
|
||||||
|
if (!(gp.base_type is ICommonTypeNode))
|
||||||
|
continue;
|
||||||
|
TypeBuilder tb = helper.GetTypeReference(gp.base_type).tp as TypeBuilder;
|
||||||
|
if (tb != null && !closed_types.Contains(tb))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tb.CreateType();
|
||||||
|
closed_types.Add(tb);
|
||||||
|
has_meth_contrains = true;
|
||||||
|
}
|
||||||
|
catch (TypeLoadException ex2)
|
||||||
|
{
|
||||||
|
throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_meth_contrains)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
failed_types.Add(value_types[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num);
|
throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
17
TestSuite/genericrecords5.pas
Normal file
17
TestSuite/genericrecords5.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
var i: integer;
|
||||||
|
type
|
||||||
|
Base = class end;
|
||||||
|
|
||||||
|
r1 = record
|
||||||
|
procedure pr1<T>(par1: T); where T: Base;
|
||||||
|
begin
|
||||||
|
i := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var r: r1;
|
||||||
|
r.pr1(new Base);
|
||||||
|
assert(i = 1);
|
||||||
|
end.
|
||||||
17
TestSuite/genericrecords6.pas
Normal file
17
TestSuite/genericrecords6.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
var i: integer;
|
||||||
|
type
|
||||||
|
Base = class end;
|
||||||
|
Base2 = class end;
|
||||||
|
r1 = record
|
||||||
|
procedure pr1<T, T2>(par1: T; par2: T2); where T: Base; where T2: Base2;
|
||||||
|
begin
|
||||||
|
i := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
var r: r1;
|
||||||
|
r.pr1(new Base, new Base2);
|
||||||
|
assert(i = 1);
|
||||||
|
end.
|
||||||
Loading…
Reference in a new issue