bug fix #2379
This commit is contained in:
Ivan Bondarev 2021-01-03 12:04:45 +01:00
parent 2ae6eadcb4
commit 34ebdb7702
5 changed files with 55 additions and 7 deletions

View file

@ -2211,6 +2211,10 @@ namespace PascalABCCompiler.PCU
ctn.type_special_kind = tsk;
if (ctn.full_name == "PABCSystem.BinaryFile")
ctn.type_special_kind = SemanticTree.type_special_kind.binary_file;
if (ctn.type_special_kind != SemanticTree.type_special_kind.set_type)
{
SystemLibrary.SystemLibrary.init_reference_type(ctn);
}
if (type_is_generic_definition)
{
foreach (common_type_node par in type_params)
@ -2219,14 +2223,11 @@ namespace PascalABCCompiler.PCU
ReadTypeParameterEliminations(par);
}
}
type_node elemnet_type = null;
type_node element_type = null;
if (CanReadObject())
elemnet_type = GetTypeReference();
ctn.element_type = elemnet_type;
if (ctn.type_special_kind != SemanticTree.type_special_kind.set_type)
{
SystemLibrary.SystemLibrary.init_reference_type(ctn);
}
element_type = GetTypeReference();
ctn.element_type = element_type;
if (ctn.type_special_kind == SemanticTree.type_special_kind.set_type)
{
ctn = compilation_context.AddTypeToSetTypeList(ctn);

View file

@ -0,0 +1,12 @@
type
t0 = class end;
t1<T> = class
where T: t0;
end;
begin
// Компилируется, а не должно
var a: t1<byte>;
end.

View file

@ -0,0 +1,12 @@
unit u_where2;
type
t0<T> = class
where T: t0<T>;
procedure p1(a: T); virtual := exit;
end;
end.

View file

@ -0,0 +1,19 @@
uses u_where2;
var i: integer;
type
t1 = class(t0<t1>)
procedure p1(a: t1); override;
begin
i := 1;
end;
end;
begin
var obj := new t1;
obj.p1(obj);
assert(i = 1);
end.

View file

@ -166,6 +166,10 @@ namespace PascalABCCompiler.TreeRealization
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_DERIVED_FROM_{1}", tn.PrintableName, base_type.name);
}
}
if (gpe.base_class != null && gpe.base_class != SystemLibrary.SystemLibrary.object_type && tn.is_value && !gpe.base_class.is_value && gpe.base_class != SystemLibrary.SystemLibrary.value_type)
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_REFERENCE_TYPE", tn.PrintableName);
}
foreach (type_node interf in gpe.implementing_interfaces)
{
type_node di = generic_convertions.determine_type(interf, tparams, method_param_types);