Fix incorrect inheritance penalty for some objects (#24144)

This fixes a logic error in  #23870
The inheritance penalty should be -1 if there is no inheritance
relationship. Not sure how to write a test case for this one honestly.

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit 37dba853c9)
This commit is contained in:
Ryan McConnell
2024-09-20 11:32:07 -04:00
committed by narimiran
parent 27381cc602
commit 78003e9f7b

View File

@@ -1398,7 +1398,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
getObjectType(a)
if effectiveArgType.kind == tyObject:
if sameObjectTypes(f, effectiveArgType):
c.inheritancePenalty = 0
c.inheritancePenalty = if tfFinal in f.flags: -1 else: 0
result = isEqual
# elif tfHasMeta in f.flags: result = recordRel(c, f, a)
elif trIsOutParam notin flags: