better fix for Issue #629 Recursive generic types not working

This commit is contained in:
Mark Flamer 2013-10-29 20:48:37 -07:00
commit 4330c986db

View file

@ -825,8 +825,6 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
of dcEqOrDistinctOf: of dcEqOrDistinctOf:
while a.kind == tyDistinct: a = a.sons[0] while a.kind == tyDistinct: a = a.sons[0]
if a.kind != b.kind: return false if a.kind != b.kind: return false
if x.Kind == tyGenericInst or y.Kind == tyGenericInst:
c.cmp = dcEqIgnoreDistinct
case a.Kind case a.Kind
of tyEmpty, tyChar, tyBool, tyNil, tyPointer, tyString, tyCString, of tyEmpty, tyChar, tyBool, tyNil, tyPointer, tyString, tyCString,
tyInt..tyBigNum, tyStmt: tyInt..tyBigNum, tyStmt:
@ -839,8 +837,13 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
result = sameObjectStructures(a, b, c) and sameFlags(a, b) result = sameObjectStructures(a, b, c) and sameFlags(a, b)
of tyDistinct: of tyDistinct:
CycleCheck() CycleCheck()
if c.cmp == dcEq: result = sameTypeAux(a, b, c) and sameFlags(a, b) if c.cmp == dcEq:
else: result = sameTypeAux(a.sons[0], b.sons[0], c) and sameFlags(a, b) result = false
if a.sym != nil and b.sym != nil:
if a.sym.name == b.sym.name:
result = sameTypeAux(a.sons[0], b.sons[0], c) and sameFlags(a, b)
else:
result = sameTypeAux(a.sons[0], b.sons[0], c) and sameFlags(a, b)
of tyEnum, tyForward, tyProxy: of tyEnum, tyForward, tyProxy:
# XXX generic enums do not make much sense, but require structural checking # XXX generic enums do not make much sense, but require structural checking
result = a.id == b.id and sameFlags(a, b) result = a.id == b.id and sameFlags(a, b)