fixes #5479
This commit is contained in:
parent
f673fbd91f
commit
7ac1e6e528
3 changed files with 31 additions and 9 deletions
|
|
@ -73,7 +73,7 @@ proc sameMethodBucket(a, b: PSym): MethodResult =
|
||||||
bb = bb.lastSon
|
bb = bb.lastSon
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if sameType(aa, bb):
|
if sameType(a.typ.sons[i], b.typ.sons[i]):
|
||||||
if aa.kind == tyObject and result != Invalid:
|
if aa.kind == tyObject and result != Invalid:
|
||||||
result = Yes
|
result = Yes
|
||||||
elif aa.kind == tyObject and bb.kind == tyObject:
|
elif aa.kind == tyObject and bb.kind == tyObject:
|
||||||
|
|
@ -83,7 +83,7 @@ proc sameMethodBucket(a, b: PSym): MethodResult =
|
||||||
result = Yes
|
result = Yes
|
||||||
else:
|
else:
|
||||||
return No
|
return No
|
||||||
elif diff != high(int):
|
elif diff != high(int) and sfFromGeneric notin (a.flags+b.flags):
|
||||||
result = Invalid
|
result = Invalid
|
||||||
else:
|
else:
|
||||||
return No
|
return No
|
||||||
|
|
|
||||||
|
|
@ -373,12 +373,17 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
else:
|
else:
|
||||||
newbody.lastSon.typeInst = result
|
newbody.lastSon.typeInst = result
|
||||||
cl.c.typesWithOps.add((newbody, result))
|
cl.c.typesWithOps.add((newbody, result))
|
||||||
let methods = skipTypes(bbody, abstractPtrs).methods
|
let mm = skipTypes(bbody, abstractPtrs)
|
||||||
for col, meth in items(methods):
|
if tfFromGeneric notin mm.flags:
|
||||||
# we instantiate the known methods belonging to that type, this causes
|
# bug #5479, prevent endless recursions here:
|
||||||
# them to be registered and that's enough, so we 'discard' the result.
|
incl mm.flags, tfFromGeneric
|
||||||
discard cl.c.instTypeBoundOp(cl.c, meth, result, cl.info,
|
let methods = mm.methods
|
||||||
attachedAsgn, col)
|
for col, meth in items(methods):
|
||||||
|
# we instantiate the known methods belonging to that type, this causes
|
||||||
|
# them to be registered and that's enough, so we 'discard' the result.
|
||||||
|
discard cl.c.instTypeBoundOp(cl.c, meth, result, cl.info,
|
||||||
|
attachedAsgn, col)
|
||||||
|
excl mm.flags, tfFromGeneric
|
||||||
|
|
||||||
proc eraseVoidParams*(t: PType) =
|
proc eraseVoidParams*(t: PType) =
|
||||||
# transform '(): void' into '()' because old parts of the compiler really
|
# transform '(): void' into '()' because old parts of the compiler really
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
output: "wow2"
|
output: '''wow2
|
||||||
|
X 1
|
||||||
|
X 3'''
|
||||||
"""
|
"""
|
||||||
type
|
type
|
||||||
First[T] = ref object of RootObj
|
First[T] = ref object of RootObj
|
||||||
|
|
@ -22,3 +24,18 @@ proc takeFirst(x: First[int]) =
|
||||||
wow(2, x)
|
wow(2, x)
|
||||||
|
|
||||||
takeFirst(x)
|
takeFirst(x)
|
||||||
|
|
||||||
|
|
||||||
|
# bug #5479
|
||||||
|
type
|
||||||
|
Base[T: static[int]] = ref object of RootObj
|
||||||
|
|
||||||
|
method test[T](t: Base[T]) {.base.} =
|
||||||
|
echo "X ", t.T
|
||||||
|
|
||||||
|
let ab = Base[1]()
|
||||||
|
|
||||||
|
ab.test()
|
||||||
|
|
||||||
|
let ac = Base[3]()
|
||||||
|
ac.test()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue