diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-12-27 18:34:28 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-12-27 18:34:28 +0200 |
commit | a27eb51535f9ff233b67e5bac80cc51b81c343c7 (patch) | |
tree | 02d29f44788e7ddc00ee9bba3381eb86d349ba6a /compiler/sigmatch.nim | |
parent | 4eea2f17d36b2cf239f0a987b5d9715a81b2b70f (diff) | |
download | Nim-a27eb51535f9ff233b67e5bac80cc51b81c343c7.tar.gz |
towards support for composite type classes such as seq[Number] and SquareMatrix[T]
Diffstat (limited to 'compiler/sigmatch.nim')
-rw-r--r-- | compiler/sigmatch.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 6a6888223..18020b95c 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -647,6 +647,8 @@ proc typeRel(c: var TCandidate, f, a: PType, doBind = true): TTypeRelation = result = typeRel(c, lastSon(f), a) of tyGenericBody: + if a.kind == tyGenericInst and a.sons[0] == f: + return isGeneric let ff = lastSon(f) if ff != nil: result = typeRel(c, ff, a) @@ -718,6 +720,17 @@ proc typeRel(c: var TCandidate, f, a: PType, doBind = true): TTypeRelation = else: result = typeRel(c, prev, a) + of tyCompositeTypeClass: + var prev = PType(idTableGet(c.bindings, f)) + if prev == nil: + if typeRel(c, f.sons[1], a) != isNone: + put(c.bindings, f, a) + return isGeneric + else: + return isNone + else: + result = typeRel(c, prev, a) + of tyGenericParam, tyTypeClass: var x = PType(idTableGet(c.bindings, f)) if x == nil: @@ -780,10 +793,13 @@ proc typeRel(c: var TCandidate, f, a: PType, doBind = true): TTypeRelation = let toMatch = if tfUnresolved in f.flags: a else: a.sons[0] result = typeRel(c, prev.sons[0], toMatch) + of tyExpr, tyStmt: result = isGeneric + of tyProxy: result = isEqual + else: internalError("typeRel: " & $f.kind) proc cmpTypes*(c: PContext, f, a: PType): TTypeRelation = |