summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-03-16 11:39:53 +0200
committerZahary Karadjov <zahary@gmail.com>2014-03-16 20:42:06 +0200
commitac271e76b18110bea8046af64ceccd6b804978dd (patch)
tree3cecf7bed8b9f5759d766e0ec9e8323277b14b7f /compiler/semexprs.nim
parent7dcf6ff50b03dfd54968383ad5a4258f040eec1b (diff)
downloadNim-ac271e76b18110bea8046af64ceccd6b804978dd.tar.gz
more robust handling of proc signatures containing inter-param type references
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 133b4ac1e..5a12156ec 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -899,10 +899,13 @@ proc makeDeref(n: PNode): PNode =
     addSon(result, a)
     t = skipTypes(t.sons[0], {tyGenericInst})
 
-proc readTypeParameter(c: PContext, ty: PType,
+const tyTypeParamsHolders = {tyGenericInst, tyCompositeTypeClass}
+
+proc readTypeParameter(c: PContext, typ: PType,
                        paramName: PIdent, info: TLineInfo): PNode =
-  internalAssert ty.kind == tyGenericInst
-  let ty = ty.skipGenericAlias
+  let ty = if typ.kind == tyGenericInst: typ.skipGenericAlias
+           else: (internalAssert typ.kind == tyCompositeTypeClass; typ.sons[1])
+  
   let tbody = ty.sons[0]
   for s in countup(0, tbody.len-2):
     let tParam = tbody.sons[s]
@@ -946,7 +949,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
         result.typ = ty
         markUsed(n, f)
         return
-    of tyGenericInst:
+    of tyTypeParamsHolders:
       return readTypeParameter(c, ty, i, n.info)
     of tyObject, tyTuple:
       if ty.n.kind == nkRecList:
@@ -996,7 +999,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
       result = n
 
   # we didn't find any field, let's look for a generic param
-  if result == nil and n.sons[0].typ.kind == tyGenericInst:
+  if result == nil and n.sons[0].typ.kind in tyTypeParamsHolders:
     result = readTypeParameter(c, n.sons[0].typ, i, n.info)
 
 proc dotTransformation(c: PContext, n: PNode): PNode =