fix overloading issue with generic invocation (#15135)
* fix overloading issue with generic alias * add test for inheritance depth
This commit is contained in:
parent
e9df8ebcfd
commit
e194cb41a4
2 changed files with 61 additions and 14 deletions
|
|
@ -579,7 +579,7 @@ proc procParamTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
|||
if f.isMetaType:
|
||||
# We are matching a generic proc (as proc param)
|
||||
# to another generic type appearing in the proc
|
||||
# signature. There is a change that the target
|
||||
# signature. There is a chance that the target
|
||||
# type is already fully-determined, so we are
|
||||
# going to try resolve it
|
||||
if c.call != nil:
|
||||
|
|
@ -1496,7 +1496,6 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
|||
#echo "inferred ", typeToString(inst), " for ", f
|
||||
return typeRel(c, inst, a)
|
||||
|
||||
var depth = 0
|
||||
if x.kind == tyGenericInvocation or f[0].kind != tyGenericBody:
|
||||
#InternalError("typeRel: tyGenericInvocation -> tyGenericInvocation")
|
||||
# simply no match for now:
|
||||
|
|
@ -1510,18 +1509,6 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
|||
# Workaround for regression #4589
|
||||
if f[i].kind != tyTypeDesc: return
|
||||
result = isGeneric
|
||||
elif x.kind == tyGenericInst and isGenericSubtype(c, x, f, depth, f) and
|
||||
(x.len - 1 == f.len):
|
||||
# do not recurse here in order to not K bind twice for this code:
|
||||
#
|
||||
# type
|
||||
# BaseFruit[T] = object of RootObj
|
||||
# Banana[T] = object of BaseFruit[uint32] # Concrete type here, not T!
|
||||
# proc setColor[K](self: var BaseFruit[K])
|
||||
# var x: Banana[float64]
|
||||
# x.setColor()
|
||||
c.inheritancePenalty += depth
|
||||
result = isGeneric
|
||||
else:
|
||||
let genericBody = f[0]
|
||||
var askip = skippedNone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue