This commit is contained in:
Ivan Bondarev 2021-02-11 19:54:05 +01:00
parent a35c670c48
commit 5d52558f98
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,10 @@
procedure p1<T>(x: T);
begin
var o := x;
var ot := o?.GetType;
assert(ot = typeof(integer));
end;
begin
p1(2);
end.

View file

@ -152,7 +152,7 @@ namespace PascalABCCompiler.TreeConverter
t = ctn1.compiled_type;
if (av.type.type_special_kind == SemanticTree.type_special_kind.array_kind)
return;
if (!av.type.is_class && !av.type.IsInterface && !(t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)))
if (!av.type.is_class && !av.type.IsInterface && !(t != null && t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) && !av.type.is_generic_parameter)
AddError(av.location, "OPERATOR_DQ_MUST_BE_USED_WITH_A_REFERENCE_TYPE_VALUETYPE");
}