This commit is contained in:
Бондарев Иван 2018-08-19 14:14:16 +02:00
parent 3c95b48083
commit 8b4b333cd0
2 changed files with 41 additions and 2 deletions

35
TestSuite/events5.pas Normal file
View file

@ -0,0 +1,35 @@
var i: integer;
j: integer;
type
TRec = record
end;
TExample<T> = class
event f: Action<T>;
event f2: Action<List<T>>;
constructor Create();
begin
f += procedure (x) -> begin i := 1; end;
f2 += procedure (x) -> begin j := 1; end;
end;
procedure raiseevent;
begin
f(default(T));
f2(new List<T>);
end;
end;
begin
var o: TExample<integer>;
o := new TExample<integer>();
o.raiseevent;
assert(i = 1);
assert(j = 1);
i := 0;
j := 0;
var o2 := new TExample<TRec>;
o2.raiseevent;
assert(i = 1);
assert(j = 1);
end.

View file

@ -196,7 +196,9 @@ namespace PascalABCCompiler.TreeConverter
el.AddElement(cfc);
SymbolInfo si = exprs[0].type.find_first_in_type(compiler_string_consts.assign_name);
if (si == null)
if (si == null && exprs[0].type.original_generic != null)
si = exprs[0].type.original_generic.find_first_in_type(compiler_string_consts.assign_name);
if (si == null)
{
throw new CompilerInternalError("Undefined delegate operation");
}
@ -223,7 +225,9 @@ namespace PascalABCCompiler.TreeConverter
el.AddElement(cfc);
SymbolInfo si = exprs[0].type.find_first_in_type(compiler_string_consts.assign_name);
if (si == null)
if (si == null && exprs[0].type.original_generic != null)
si = exprs[0].type.original_generic.find_first_in_type(compiler_string_consts.assign_name);
if (si == null)
{
throw new CompilerInternalError("Undefined delegate operation");
}