bug fix #3060
This commit is contained in:
parent
1d82d488a4
commit
cbaff8cfd0
|
|
@ -10292,12 +10292,23 @@ namespace PascalABCCompiler.NETGenerator
|
|||
if (temp_is_dot_expr)
|
||||
{
|
||||
if (elem_type.IsGenericParameter)
|
||||
{
|
||||
if (value.array.type.element_type.is_generic_parameter && value.array.type.element_type.base_type != null && value.array.type.element_type.base_type.is_class && value.array.type.element_type.base_type.base_type != null)
|
||||
{
|
||||
if (indices == null)
|
||||
il.Emit(OpCodes.Ldelem_Ref);
|
||||
else
|
||||
il.Emit(OpCodes.Call, get_meth);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (indices == null)
|
||||
il.Emit(OpCodes.Ldelema, elem_type);
|
||||
else
|
||||
il.Emit(OpCodes.Call, addr_meth);
|
||||
}
|
||||
|
||||
}
|
||||
else if (elem_type.IsValueType == true)
|
||||
{
|
||||
if (indices == null)
|
||||
|
|
|
|||
26
TestSuite/generics75.pas
Normal file
26
TestSuite/generics75.pas
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
var s: string;
|
||||
type
|
||||
c1<TSelf> = class
|
||||
where TSelf: c1<TSelf>;
|
||||
x: string := 'abc';
|
||||
|
||||
static a := new TSelf[1];
|
||||
|
||||
static procedure p1;
|
||||
begin
|
||||
assert((a[0] as c1<TSelf>).x.Length = 3); // 3
|
||||
s := a[0].x; // nil
|
||||
a[0].x := 'abc';
|
||||
assert((a[0] as c1<TSelf>).x.Length = 3); // 0
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
c2 = class(c1<c2>) end;
|
||||
|
||||
begin
|
||||
c2.a[0] := new c2;
|
||||
c2.p1;
|
||||
assert(c2.a[0].x.Length = 3); // 0
|
||||
assert(s = 'abc');
|
||||
end.
|
||||
Loading…
Reference in a new issue