mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 03:44:14 +00:00
fixes #1919
This commit is contained in:
@@ -608,12 +608,6 @@ proc addInheritedFieldsAux(c: PContext, check: var IntSet, pos: var int,
|
||||
incl(check, n.sym.name.id)
|
||||
inc(pos)
|
||||
else: internalError(n.info, "addInheritedFieldsAux()")
|
||||
|
||||
proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
|
||||
obj: PType) =
|
||||
if (sonsLen(obj) > 0) and (obj.sons[0] != nil):
|
||||
addInheritedFields(c, check, pos, obj.sons[0])
|
||||
addInheritedFieldsAux(c, check, pos, obj.n)
|
||||
|
||||
proc skipGenericInvokation(t: PType): PType {.inline.} =
|
||||
result = t
|
||||
@@ -622,6 +616,13 @@ proc skipGenericInvokation(t: PType): PType {.inline.} =
|
||||
if result.kind == tyGenericBody:
|
||||
result = lastSon(result)
|
||||
|
||||
proc addInheritedFields(c: PContext, check: var IntSet, pos: var int,
|
||||
obj: PType) =
|
||||
assert obj.kind == tyObject
|
||||
if (sonsLen(obj) > 0) and (obj.sons[0] != nil):
|
||||
addInheritedFields(c, check, pos, obj.sons[0].skipGenericInvokation)
|
||||
addInheritedFieldsAux(c, check, pos, obj.n)
|
||||
|
||||
proc semObjectNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
if n.sonsLen == 0: return newConstraint(c, tyObject)
|
||||
var check = initIntSet()
|
||||
|
||||
19
tests/generics/tgeneric_inheritance.nim
Normal file
19
tests/generics/tgeneric_inheritance.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
discard """
|
||||
output: '0.0'
|
||||
"""
|
||||
|
||||
# bug #1919
|
||||
|
||||
type
|
||||
Base[M] = object of RootObj
|
||||
a : M
|
||||
|
||||
Sub1[M] = object of Base[M]
|
||||
b : int
|
||||
|
||||
Sub2[M] = object of Sub1[M]
|
||||
c : int
|
||||
|
||||
var x: Sub2[float]
|
||||
|
||||
echo x.a
|
||||
Reference in New Issue
Block a user