This commit is contained in:
Andreas Rumpf 2019-06-02 06:33:35 +02:00 • committed by GitHub
commit 4a35d2b571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 9 deletions

View file

@ -1480,6 +1480,15 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
#InternalError("typeRel: tyGenericInvocation -> tyGenericInvocation")
# simply no match for now:
discard
elif x.kind == tyGenericInst and f.sons[0] == x.sons[0] and
sonsLen(x) - 1 == sonsLen(f):
for i in 1 ..< sonsLen(f):
if x.sons[i].kind == tyGenericParam:
internalError(c.c.graph.config, "wrong instantiated type!")
elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype:
# Workaround for regression #4589
if f.sons[i].kind != tyTypeDesc: return
result = isGeneric
elif x.kind == tyGenericInst and isGenericSubType(c, x, f, depth, f) and
(sonsLen(x) - 1 == sonsLen(f)):
# do not recurse here in order to not K bind twice for this code:
@ -1492,15 +1501,6 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
# x.setColor()
c.inheritancePenalty += depth
result = isGeneric
elif x.kind == tyGenericInst and f.sons[0] == x.sons[0] and
sonsLen(x) - 1 == sonsLen(f):
for i in 1 ..< sonsLen(f):
if x.sons[i].kind == tyGenericParam:
internalError(c.c.graph.config, "wrong instantiated type!")
elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype:
# Workaround for regression #4589
if f.sons[i].kind != tyTypeDesc: return
result = isGeneric
else:
let genericBody = f.sons[0]
var askip = skippedNone