From cdc6529ccfbbabebf9e0da98334e1c4ee6e3973b Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 3 Jul 2015 00:14:54 +0200 Subject: [PATCH] fixes #3038 --- compiler/semtypes.nim | 4 ++-- tests/objects/trefobjsyntax3.nim | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/objects/trefobjsyntax3.nim diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index ff68373c4b..d0cd709475 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -629,7 +629,7 @@ proc skipGenericInvocation(t: PType): PType {.inline.} = result = t if result.kind == tyGenericInvocation: result = result.sons[0] - while result.kind in {tyGenericInst, tyGenericBody}: + while result.kind in {tyGenericInst, tyGenericBody, tyRef, tyPtr}: result = lastSon(result) proc addInheritedFields(c: PContext, check: var IntSet, pos: var int, @@ -651,7 +651,7 @@ proc semObjectNode(c: PContext, n: PNode, prev: PType): PType = if base.isNil: localError(n.info, errIllegalRecursionInTypeX, "object") else: - var concreteBase = skipGenericInvocation(base).skipTypes(skipPtrs) + var concreteBase = skipGenericInvocation(base) if concreteBase.kind == tyObject and tfFinal notin concreteBase.flags: addInheritedFields(c, check, pos, concreteBase) else: diff --git a/tests/objects/trefobjsyntax3.nim b/tests/objects/trefobjsyntax3.nim new file mode 100644 index 0000000000..2d466eedae --- /dev/null +++ b/tests/objects/trefobjsyntax3.nim @@ -0,0 +1,28 @@ +# bug #2540 + +type + BaseSceneNode[T] = ref object of RootObj + children*: seq[BaseSceneNode[T]] + parent*: BaseSceneNode[T] + + SceneNode[T] = ref object of BaseSceneNode[T] + + SomeObj = ref object + +proc newSceneNode[T](): SceneNode[T] = + new result + result.children = @[] + +var aNode = newSceneNode[SomeObj]() + + +# bug #3038 + +type + Data[T] = ref object of RootObj + data: T + Type = ref object of RootObj + SubType[T] = ref object of Type + data: Data[T] + SubSubType = ref object of SubType + SubSubSubType = ref object of SubSubType