minor improvement towards tgenericshardcases
This commit is contained in:
parent
52b00630c8
commit
01ccb52a00
4 changed files with 42 additions and 24 deletions
|
|
@ -431,6 +431,9 @@ proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope =
|
|||
appf(result, "$N$1}", [spaces(indent)])
|
||||
|
||||
proc debug(n: PSym) =
|
||||
if n == nil:
|
||||
writeln(stdout, "null")
|
||||
else:
|
||||
#writeln(stdout, ropeToStr(symToYaml(n, 0, 1)))
|
||||
writeln(stdout, ropeToStr(ropef("$1_$2: $3, $4", [
|
||||
toRope(n.name.s), toRope(n.id), flagsToStr(n.flags),
|
||||
|
|
|
|||
|
|
@ -248,7 +248,11 @@ proc semLowHigh(c: PContext, n: PNode, m: TMagic): PNode =
|
|||
of tyInt..tyInt64, tyChar, tyBool, tyEnum, tyUInt8, tyUInt16, tyUInt32:
|
||||
# do not skip the range!
|
||||
n.typ = n.sons[1].typ.skipTypes(abstractVar)
|
||||
else: LocalError(n.info, errInvalidArgForX, opToStr[m])
|
||||
of tyGenericParam:
|
||||
# leave it for now, it will be resolved in semtypinst
|
||||
n.typ = getSysType(tyInt)
|
||||
else:
|
||||
LocalError(n.info, errInvalidArgForX, opToStr[m])
|
||||
result = n
|
||||
|
||||
proc semSizeof(c: PContext, n: PNode): PNode =
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
|
|||
header.sons[i] = x
|
||||
propagateToOwner(header, x)
|
||||
#idTablePut(cl.typeMap, body.sons[i-1], x)
|
||||
|
||||
if header != nil:
|
||||
# search again after first pass:
|
||||
result = searchInstTypes(header)
|
||||
|
|
@ -200,6 +201,9 @@ proc ReplaceTypeVarsT*(cl: var TReplTypeVars, t: PType): PType =
|
|||
result = lookupTypeVar(cl, t)
|
||||
if result.kind == tyGenericInvokation:
|
||||
result = handleGenericInvokation(cl, result)
|
||||
of tyExpr:
|
||||
if t.sym != nil and t.sym.kind == skGenericParam:
|
||||
result = lookupTypeVar(cl, t)
|
||||
of tyGenericInvokation:
|
||||
result = handleGenericInvokation(cl, t)
|
||||
of tyGenericBody:
|
||||
|
|
|
|||
|
|
@ -618,6 +618,9 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
|||
result = typeRel(c, f.sons[0], a.sons[0])
|
||||
else:
|
||||
result = isNone
|
||||
else:
|
||||
if a.kind == tyTypeClass:
|
||||
result = isGeneric
|
||||
else:
|
||||
result = matchTypeClass(c, f, a)
|
||||
|
||||
|
|
@ -781,6 +784,10 @@ proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
|||
of tyExpr:
|
||||
if fMaybeExpr.sonsLen == 0:
|
||||
r = isGeneric
|
||||
else:
|
||||
if a.kind == tyExpr:
|
||||
InternalAssert a.len > 0
|
||||
r = typeRel(m, f.lastSon, a.lastSon)
|
||||
else:
|
||||
let match = matchTypeClass(m, fMaybeExpr, a)
|
||||
if match != isGeneric: r = isNone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue