This commit is contained in:
Araq 2013-08-31 11:49:33 +02:00
commit b40ab4dc9e
3 changed files with 34 additions and 4 deletions

View file

@ -775,8 +775,11 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and
aa.sons[0].kind == nkObjectTy: aa.sons[0].kind == nkObjectTy:
# give anonymous object a dummy symbol: # give anonymous object a dummy symbol:
assert s.typ.sons[0].sym == nil var st = s.typ
s.typ.sons[0].sym = newSym(skType, getIdent(s.name.s & ":ObjectType"), if st.kind == tyGenericBody: st = st.lastSon
InternalAssert st.kind in {tyPtr, tyRef}
InternalAssert st.sons[0].sym == nil
st.sons[0].sym = newSym(skType, getIdent(s.name.s & ":ObjectType"),
getCurrOwner(), s.info) getCurrOwner(), s.info)
proc SemTypeSection(c: PContext, n: PNode): PNode = proc SemTypeSection(c: PContext, n: PNode): PNode =

View file

@ -558,7 +558,7 @@ proc semObjectNode(c: PContext, n: PNode, prev: PType): PType =
checkSonsLen(n, 3) checkSonsLen(n, 3)
if n.sons[1].kind != nkEmpty: if n.sons[1].kind != nkEmpty:
base = skipTypes(semTypeNode(c, n.sons[1].sons[0], nil), skipPtrs) base = skipTypes(semTypeNode(c, n.sons[1].sons[0], nil), skipPtrs)
var concreteBase = skipGenericInvokation(base) var concreteBase = skipGenericInvokation(base).skipTypes(skipPtrs)
if concreteBase.kind == tyObject and tfFinal notin concreteBase.flags: if concreteBase.kind == tyObject and tfFinal notin concreteBase.flags:
addInheritedFields(c, check, pos, concreteBase) addInheritedFields(c, check, pos, concreteBase)
else: else:

View file

@ -0,0 +1,27 @@
discard """
output: "23"
"""
# bug #554, #179
type T[E] =
ref object
elem: E
var ob: T[int]
ob = T[int](elem: 23)
echo ob.elem
type
TTreeIteratorA* = ref object {.inheritable.}
TKeysIteratorA* = ref object of TTreeIteratorA #compiles
TTreeIterator* [T,D] = ref object {.inheritable.}
TKeysIterator* [T,D] = ref object of TTreeIterator[T,D] #this not
var
it: TKeysIterator[int, string] = nil