fixes subtype relation regression

This commit is contained in:
Araq
2019-05-21 18:40:31 +02:00
committed by Andreas Rumpf
parent 1f7f0908ef
commit 57bc8d73b4
2 changed files with 21 additions and 5 deletions

View File

@@ -130,9 +130,8 @@ proc put(c: var TCandidate, key, val: PType) {.inline.} =
echo "Putting ", typeToString(key), " ", typeToString(val), " and old is ", typeToString(old)
if typeToString(old) == "seq[string]":
writeStackTrace()
if typeToString(key) == "K":
echo "putting to K ", typeToString(val)
writeStackTrace()
if c.c.module.name.s == "temp3":
echo "binding ", key, " -> ", val
idTablePut(c.bindings, key, val.skipIntLit)
proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PSym,
@@ -1392,6 +1391,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
if roota.base == rootf.base:
let nextFlags = flags + {trNoCovariance}
var hasCovariance = false
# YYYY
result = isEqual
for i in 1 .. rootf.sonsLen-2:
@@ -1437,7 +1437,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
let baseType = aAsObject.base
if baseType != nil:
c.inheritancePenalty += 1
return typeRel(c, f, baseType)
let ret = typeRel(c, f, baseType)
return if ret == isEqual: isSubtype else: ret
result = isNone
else:
@@ -1793,6 +1794,21 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
else:
internalError c.c.graph.config, " unknown type kind " & $f.kind
when false:
var nowDebug = false
var dbgCount = 0
proc typeRel(c: var TCandidate, f, aOrig: PType,
flags: TTypeRelFlags = {}): TTypeRelation =
if nowDebug:
echo f, " <- ", aOrig
inc dbgCount
if dbgCount == 2:
writeStackTrace()
result = typeRelImpl(c, f, aOrig, flags)
if nowDebug:
echo f, " <- ", aOrig, " res ", result
proc cmpTypes*(c: PContext, f, a: PType): TTypeRelation =
var m: TCandidate
initCandidate(c, m, f)

View File

@@ -194,7 +194,7 @@ block tproctypecache_falsepositive:
block tptrinheritance:
type NSPasteboardItem = ptr object
type NSPasteboard = ptr object
type NSArrayAbstract = ptr object {.inheritable.}
type NSArrayAbstract {.inheritable.} = ptr object
type NSMutableArrayAbstract = ptr object of NSArrayAbstract
type NSArray[T] = ptr object of NSArrayAbstract
type NSMutableArray[T] = ptr object of NSArray[T]