fixes #3038
This commit is contained in:
parent
3df9d2bd0c
commit
cdc6529ccf
2 changed files with 30 additions and 2 deletions
|
|
@ -629,7 +629,7 @@ proc skipGenericInvocation(t: PType): PType {.inline.} =
|
||||||
result = t
|
result = t
|
||||||
if result.kind == tyGenericInvocation:
|
if result.kind == tyGenericInvocation:
|
||||||
result = result.sons[0]
|
result = result.sons[0]
|
||||||
while result.kind in {tyGenericInst, tyGenericBody}:
|
while result.kind in {tyGenericInst, tyGenericBody, tyRef, tyPtr}:
|
||||||
result = lastSon(result)
|
result = lastSon(result)
|
||||||
|
|
||||||
proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
|
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:
|
if base.isNil:
|
||||||
localError(n.info, errIllegalRecursionInTypeX, "object")
|
localError(n.info, errIllegalRecursionInTypeX, "object")
|
||||||
else:
|
else:
|
||||||
var concreteBase = skipGenericInvocation(base).skipTypes(skipPtrs)
|
var concreteBase = skipGenericInvocation(base)
|
||||||
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:
|
||||||
|
|
|
||||||
28
tests/objects/trefobjsyntax3.nim
Normal file
28
tests/objects/trefobjsyntax3.nim
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue