This commit is contained in:
parent
5664851b72
commit
207bfde593
|
|
@ -50,6 +50,7 @@ namespace PascalABCCompiler.NETGenerator
|
|||
public static Type ValueType = typeof(ValueType);
|
||||
public static Type IEnumerableType = typeof(System.Collections.IEnumerable);
|
||||
public static Type IEnumeratorType = typeof(System.Collections.IEnumerator);
|
||||
public static Type IDisposableType = typeof(IDisposable);
|
||||
public static Type IEnumerableGenericType = typeof(System.Collections.Generic.IEnumerable<>);
|
||||
public static Type IEnumeratorGenericType = typeof(System.Collections.Generic.IEnumerator<>);
|
||||
|
||||
|
|
|
|||
|
|
@ -11620,8 +11620,11 @@ namespace PascalABCCompiler.NETGenerator
|
|||
//il.Emit(OpCodes.Leave, leave_label);
|
||||
il.BeginFinallyBlock();
|
||||
//il.MarkLabel(br_lbl);
|
||||
il.Emit(OpCodes.Ldnull);
|
||||
il.Emit(OpCodes.Stloc, lb);
|
||||
if (lb.LocalType.IsValueType)
|
||||
il.Emit(OpCodes.Ldloca, lb);
|
||||
else
|
||||
il.Emit(OpCodes.Ldloc, lb);
|
||||
il.Emit(OpCodes.Callvirt, TypeFactory.IDisposableType.GetMethod("Dispose", BindingFlags.Instance | BindingFlags.Public));
|
||||
|
||||
il.EndExceptionBlock();
|
||||
il.MarkLabel(leave_label);
|
||||
|
|
|
|||
31
TestSuite/foreach12.pas
Normal file
31
TestSuite/foreach12.pas
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
var c := 0;
|
||||
|
||||
type
|
||||
t1 = class(IEnumerable<byte>, IEnumerator<byte>)
|
||||
|
||||
public function GetEnumerator: IEnumerator<byte> := self;
|
||||
function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator := self;
|
||||
|
||||
public function MoveNext := false;
|
||||
|
||||
public property Current: byte read 0;
|
||||
property System.Collections.IEnumerator.Current: object read 0;
|
||||
|
||||
public procedure Reset := exit;
|
||||
|
||||
public procedure Dispose := c += 1;
|
||||
|
||||
end;
|
||||
|
||||
function f1: sequence of byte;
|
||||
begin
|
||||
yield sequence new t1;
|
||||
foreach var x in new t1 do
|
||||
yield x;
|
||||
foreach var x in new t1 do ;
|
||||
end;
|
||||
|
||||
begin
|
||||
foreach var x in new t1 do ;
|
||||
Assert(c = 1);
|
||||
end.
|
||||
Loading…
Reference in a new issue