This commit is contained in:
Бондарев Иван 2020-03-15 17:57:06 +01:00
parent 4d0adaef12
commit 43cf831ba3
2 changed files with 15 additions and 1 deletions

14
TestSuite/where11.pas Normal file
View file

@ -0,0 +1,14 @@
type
t1<T> = class where T: t1<T>;
function p1: T;
begin
var a: t1<T>;
var b := a as T;
end;
end;
begin
end.

View file

@ -3085,7 +3085,7 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
if (tp.is_generic_parameter && !tp.is_class && !(tp.base_type != null && tp.base_type.is_class))
if (tp.is_generic_parameter && !tp.is_class && !(tp.base_type != null && tp.base_type.is_class) && !(tp.base_type != null && tp.base_type.original_generic != null && tp.base_type.original_generic.is_class))
AddError(get_location(node.type_def), "OPERATOR_AS_CAN_NOT_BE_USED_WITH_GENERIC_PARAMETER_{0}_WITHOUT_CLASS_CONSTRAINT", tp.name);
if (tp.is_value_type)
AddError(get_location(node.type_def), "OPERATOR_AS_MUST_BE_USED_WITCH_A_REFERENCE_TYPE_VALUETYPE{0}", tp.PrintableName);