fixes #6526
This commit is contained in:
parent
8c94a00e02
commit
9c00f6decd
3 changed files with 36 additions and 15 deletions
|
|
@ -1452,8 +1452,13 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
|||
of tyOr:
|
||||
considerPreviousT:
|
||||
result = isNone
|
||||
let oldInheritancePenalty = c.inheritancePenalty
|
||||
var maxInheritance = 0
|
||||
for branch in f.sons:
|
||||
c.inheritancePenalty = 0
|
||||
let x = typeRel(c, branch, aOrig)
|
||||
maxInheritance = max(maxInheritance, c.inheritancePenalty)
|
||||
|
||||
# 'or' implies maximum matching result:
|
||||
if x > result: result = x
|
||||
if result >= isSubtype:
|
||||
|
|
@ -1461,6 +1466,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
|||
bindingRet result
|
||||
else:
|
||||
result = isNone
|
||||
c.inheritancePenalty = oldInheritancePenalty + maxInheritance
|
||||
|
||||
of tyNot:
|
||||
considerPreviousT:
|
||||
|
|
@ -1551,21 +1557,19 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
|||
result = isNone
|
||||
else:
|
||||
if f.sonsLen > 0 and f.sons[0].kind != tyNone:
|
||||
when false:
|
||||
let oldInheritancePenalty = c.inheritancePenalty
|
||||
let oldInheritancePenalty = c.inheritancePenalty
|
||||
result = typeRel(c, f.lastSon, a, flags + {trDontBind})
|
||||
if doBind and result notin {isNone, isGeneric}:
|
||||
let concrete = concreteType(c, a)
|
||||
if concrete == nil: return isNone
|
||||
put(c, f, concrete)
|
||||
when false:
|
||||
# bug #6526
|
||||
if result in {isEqual, isSubtype}:
|
||||
# 'T: Class' is a *better* match than just 'T'
|
||||
# but 'T: Subclass' is even better:
|
||||
c.inheritancePenalty = oldInheritancePenalty - c.inheritancePenalty -
|
||||
100 * ord(result == isEqual)
|
||||
result = isGeneric
|
||||
# bug #6526
|
||||
if result in {isEqual, isSubtype}:
|
||||
# 'T: Class' is a *better* match than just 'T'
|
||||
# but 'T: Subclass' is even better:
|
||||
c.inheritancePenalty = oldInheritancePenalty - c.inheritancePenalty -
|
||||
100 * ord(result == isEqual)
|
||||
result = isGeneric
|
||||
else:
|
||||
result = isGeneric
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue