Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var i: integer; | ||
|
||
type | ||
e1 = class(System.Collections.IEnumerator) | ||
public function MoveNext := false; | ||
public function get_current:object := nil; | ||
public procedure Reset := exit; | ||
end; | ||
e2<T> = class(System.Collections.Generic.IEnumerator<T>) | ||
public function MoveNext := false; | ||
public function System.Collections.IEnumerator.get_current:object := nil; | ||
public function get_current:T := default(T); | ||
public procedure Reset := exit; | ||
public procedure Dispose := exit; | ||
end; | ||
|
||
t2=class | ||
b:byte; | ||
end; | ||
t1<T> = class(System.Collections.Generic.IEnumerable<T>) | ||
|
||
public function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator; | ||
begin | ||
i := 1; | ||
Result := new e1; | ||
end; | ||
|
||
public function GetEnumerator: System.Collections.Generic.IEnumerator<T>; | ||
begin | ||
i := 2; | ||
Result := new e2<T>; | ||
end; | ||
|
||
end; | ||
|
||
begin | ||
foreach var o in new t1<t2> do | ||
o.b := 2; | ||
assert(i = 2); | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function test<T>(a: T): sequence of T; | ||
begin | ||
var lst: List<List<T>> := new List<List<T>>; | ||
lst.Add(new List<T>(Arr(a, a))); | ||
foreach var x in lst do | ||
begin | ||
yield x[0]; | ||
end; | ||
end; | ||
begin | ||
assert(test(2).ToArray[0] = 2); | ||
end. |