summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-02-18 20:04:58 +0200
committerZahary Karadjov <zahary@gmail.com>2014-02-18 20:04:58 +0200
commit0bbf6081d00e83329021a0051d92c3433fc8a00f (patch)
treed664b9e5062269271e166d9be5dff5f823884de8 /compiler
parentf13a836972abd29d5362ac4cc949aa8e0470f962 (diff)
downloadNim-0bbf6081d00e83329021a0051d92c3433fc8a00f.tar.gz
fix #931 and few more tests
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semtypes.nim1
-rw-r--r--compiler/semtypinst.nim9
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 98abaf005..0eba602cc 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -705,7 +705,6 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
       # result.rawAddSon(copyType(paramType.sons[i], getCurrOwner(), true))
     result = instGenericContainer(c, paramType.sym.info, result,
                                   allowMetaTypes = true)
-    result.lastSon.shouldHaveMeta
     result = newTypeWithSons(c, tyCompositeTypeClass, @[paramType, result])
     result = addImplicitGeneric(result)
   
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index f08214f1e..22edc6e32 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -220,7 +220,7 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
   # is difficult to handle: 
   var body = t.sons[0]
   if body.kind != tyGenericBody: internalError(cl.info, "no generic body")
-  var header: PType = nil
+  var header: PType = t
   # search for some instantiation here:
   if cl.allowMetaTypes:
     result = PType(idTableGet(cl.localCache, t))
@@ -232,11 +232,13 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
     if x.kind == tyGenericParam:
       x = lookupTypeVar(cl, x)
       if x != nil:
-        if header == nil: header = instCopyType(cl, t)
+        if header == t: header = instCopyType(cl, t)
         header.sons[i] = x
         propagateToOwner(header, x)
+    else:
+      propagateToOwner(header, x)
   
-  if header != nil:
+  if header != t:
     # search again after first pass:
     result = searchInstTypes(header)
     if result != nil: return
@@ -244,6 +246,7 @@ proc handleGenericInvokation(cl: var TReplTypeVars, t: PType): PType =
     header = instCopyType(cl, t)
   
   result = newType(tyGenericInst, t.sons[0].owner)
+  result.flags = header.flags
   # be careful not to propagate unnecessary flags here (don't use rawAddSon)
   result.sons = @[header.sons[0]]
   # ugh need another pass for deeply recursive generic types (e.g. PActor)