Merge pull request #1992 from SunSerega/where-fixes
Исправление issue#1986
This commit is contained in:
commit
828db9e1fb
|
|
@ -5433,8 +5433,9 @@ namespace PascalABCCompiler.NETGenerator
|
|||
{
|
||||
if (lb.LocalType.IsGenericParameter)
|
||||
{
|
||||
il.Emit(OpCodes.Ldloc, lb);
|
||||
il.Emit(OpCodes.Box, lb.LocalType);
|
||||
//il.Emit(OpCodes.Ldloc, lb);
|
||||
//il.Emit(OpCodes.Box, lb.LocalType);
|
||||
il.Emit(OpCodes.Ldloca, lb); // #1986
|
||||
}
|
||||
else
|
||||
if (lb.LocalType.IsValueType)
|
||||
|
|
|
|||
28
TestSuite/where8.pas
Normal file
28
TestSuite/where8.pas
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
type
|
||||
t0 = abstract class
|
||||
function f0: integer; abstract;
|
||||
end;
|
||||
t1 = class(t0)
|
||||
i: integer;
|
||||
function f0: integer; override := i;
|
||||
constructor(i: integer) := self.i := i;
|
||||
end;
|
||||
|
||||
function f1<T>: T;
|
||||
where T: t0;
|
||||
begin
|
||||
|
||||
Result := T(t0(
|
||||
new t1(10)
|
||||
));
|
||||
|
||||
Result.f0.Println; // до #1986 было AccessViolationException
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
|
||||
f1&<t1>;
|
||||
|
||||
// readln;
|
||||
end.
|
||||
18
TestSuite/where9.pas
Normal file
18
TestSuite/where9.pas
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function f1<TArray>: TArray;
|
||||
where TArray: System.Array;
|
||||
begin
|
||||
|
||||
Result := TArray(System.Array(
|
||||
new integer[10]
|
||||
));
|
||||
|
||||
Result.Length.Println; // до #1986 выводило 107, не зависимо от массива выше
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
|
||||
f1&<array of integer>;
|
||||
|
||||
// readln;
|
||||
end.
|
||||
Loading…
Reference in a new issue