support for accessing the inferred concept type params with the dot operator

This commit is contained in:
Zahary Karadjov 2016-07-29 18:12:05 +03:00
commit eab1d0cc02
6 changed files with 24 additions and 7 deletions

View file

@ -642,7 +642,7 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
# We need to put them in the current sigmatch's binding table in order for them
# to be resolvable while matching the rest of the parameters
for p in typeParams:
put(m.bindings, p[0].typ, p[1])
put(m.bindings, p[1], p[0].typ)
return isGeneric
@ -716,6 +716,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
tyGenericInst, tyGenericParam} + tyTypeClasses:
return typeRel(c, f, lastSon(a))
if a.isResolvedUserTypeClass:
return typeRel(c, f, a.lastSon)
template bindingRet(res) =
if doBind:
let bound = aOrig.skipTypes({tyRange}).skipIntLit
@ -1125,12 +1128,20 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
else:
return isNone
of tyUserTypeClass, tyUserTypeClassInst:
of tyUserTypeClass:
considerPreviousT:
result = matchUserTypeClass(c.c, c, f, aOrig)
if result == isGeneric:
put(c, f, a)
of tyUserTypeClassInst:
considerPreviousT:
result = matchUserTypeClass(c.c, c, f, aOrig)
if result == isGeneric:
var fWithResolvedParams = generateTypeInstance(c.c, c.bindings, c.call.info, f)
fWithResolvedParams.sons.add a
put(c.bindings, f, fWithResolvedParams)
of tyCompositeTypeClass:
considerPreviousT:
let roota = a.skipGenericAlias
@ -1397,7 +1408,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType,
arg = argSemantized
argType = argType
c = m.c
if inferTypeClassParam(c, f, argType):
return argSemantized