fixes subtype relation regression

This commit is contained in:
Araq 2019-05-21 18:40:31 +02:00 • committed by Andreas Rumpf
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) echo "Putting ", typeToString(key), " ", typeToString(val), " and old is ", typeToString(old)
if typeToString(old) == "seq[string]": if typeToString(old) == "seq[string]":
writeStackTrace() writeStackTrace()
if typeToString(key) == "K": if c.c.module.name.s == "temp3":
echo "putting to K ", typeToString(val) echo "binding ", key, " -> ", val
writeStackTrace()
idTablePut(c.bindings, key, val.skipIntLit) idTablePut(c.bindings, key, val.skipIntLit)
proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PSym, 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: if roota.base == rootf.base:
let nextFlags = flags + {trNoCovariance} let nextFlags = flags + {trNoCovariance}
var hasCovariance = false var hasCovariance = false
# YYYY
result = isEqual result = isEqual
for i in 1 .. rootf.sonsLen-2: for i in 1 .. rootf.sonsLen-2:
@ -1437,7 +1437,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
let baseType = aAsObject.base let baseType = aAsObject.base
if baseType != nil: if baseType != nil:
c.inheritancePenalty += 1 c.inheritancePenalty += 1
return typeRel(c, f, baseType) let ret = typeRel(c, f, baseType)
return if ret == isEqual: isSubtype else: ret
result = isNone result = isNone
else: else:
@ -1793,6 +1794,21 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
else: else:
internalError c.c.graph.config, " unknown type kind " & $f.kind 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 = proc cmpTypes*(c: PContext, f, a: PType): TTypeRelation =
var m: TCandidate var m: TCandidate
initCandidate(c, m, f) initCandidate(c, m, f)

View file

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