borrow works with generics

This commit is contained in:
Araq 2012-08-06 18:11:03 +02:00
commit ce23b814a0
6 changed files with 79 additions and 42 deletions

View file

@ -1108,3 +1108,17 @@ proc containsGenericTypeIter(t: PType, closure: PObject): bool =
proc containsGenericType*(t: PType): bool =
result = iterOverType(t, containsGenericTypeIter, nil)
proc baseOfDistinct*(t: PType): PType =
if t.kind == tyDistinct:
result = t.sons[0]
else:
result = copyType(t, t.owner, false)
var parent: PType = nil
var it = result
while it.kind in {tyPtr, tyRef}:
parent = it
it = it.sons[0]
if it.kind == tyDistinct:
internalAssert parent != nil
parent.sons[0] = it.sons[0]