This commit is contained in:
Бондарев Иван 2019-06-10 14:27:44 +02:00
parent c95b0aa94d
commit 4aaa4c2a3b
2 changed files with 22 additions and 0 deletions

20
TestSuite/generics27.pas Normal file
View file

@ -0,0 +1,20 @@
type
t1 = class end;
procedure p2<T>(a: T); where T:class;
begin
assert(a = nil);
end;
procedure p1<T>; where T: t1;
begin
var a: T;
var b: t1;
a := b as T;
p2&<t1>(b);
assert(a = nil);
end;
begin
p1&<t1>;
end.

View file

@ -12361,6 +12361,8 @@ namespace PascalABCCompiler.TreeConverter
type_node spec_type = ret.visit(ntr); type_node spec_type = ret.visit(ntr);
if (spec_type is ref_type_node || spec_type == SystemLibrary.SystemLibrary.void_type || spec_type == SystemLibrary.SystemLibrary.pointer_type) if (spec_type is ref_type_node || spec_type == SystemLibrary.SystemLibrary.void_type || spec_type == SystemLibrary.SystemLibrary.pointer_type)
AddError(new SimpleSemanticError(get_location(specificators[i]), "INAVLID_TYPE")); AddError(new SimpleSemanticError(get_location(specificators[i]), "INAVLID_TYPE"));
if (spec_type.is_class)
param.is_class = true;
if (spec_type.IsInterface) if (spec_type.IsInterface)
{ {
if (used_interfs[spec_type] != null) if (used_interfs[spec_type] != null)