@@ -33,6 +33,7 @@ proc instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable,
3333 # t = instGenericContainer(c, a, t)
3434 t = generateTypeInstance (c, pt, a, t)
3535 # t = ReplaceTypeVarsT(cl, t)
36+ t.flags.incl tfInstantiated
3637 s.typ = t
3738 addDecl (c, s)
3839 entry.concreteTypes[i] = t
@@ -41,7 +42,8 @@ proc sameInstantiation(a, b: TInstantiatedSymbol): bool =
4142 if a.genericSym.id == b.genericSym.id and
4243 a.concreteTypes.len == b.concreteTypes.len:
4344 for i in 0 .. < a.concreteTypes.len:
44- if not sameType (a.concreteTypes[i], b.concreteTypes[i]): return
45+ if not compareTypes (a.concreteTypes[i], b.concreteTypes[i],
46+ flags = {TypeDescExactMatch }): return
4547 result = true
4648
4749proc GenericCacheGet (c: PContext , entry: var TInstantiatedSymbol ): PSym =
@@ -122,33 +124,6 @@ proc sideEffectsCheck(c: PContext, s: PSym) =
122124 s.ast.sons[genericParamsPos].kind == nkEmpty:
123125 c.threadEntries.add (s)
124126
125- proc applyConcreteTypesToSig (genericProc: PSym , concTypes: seq [PType ]): PType =
126- # XXX: This is intended to replace the use of semParamList in generateInstance.
127- # The results of semParamList's analysis are already encoded in the original
128- # proc type and any concrete types may be aplied directly over it.
129- # Besides being more efficient, it will remove the awkward case of
130- # genericParams == nil in semParamList.
131- # Currenly, it fails in some cases such as:
132- # proc inc2*[T](x: var ordinal[T], y = 1) {.magic: "Inc", noSideEffect.}
133- let sig = genericProc.typ
134- result = copyType (sig, getCurrOwner (), false )
135- result .n = sig.n.shallowCopy
136-
137- for i in countup (0 , sig.len - 1 ):
138- let tOrig = sig.sons[i]
139- if tOrig == nil : continue
140- let oGenParams = genericProc.ast.sons[genericParamsPos]
141- if skipTypes (tOrig, skipPtrs).kind in {tyGenericParam}:
142- var tConcrete = concTypes[tOrig.sym.position]
143- if i > 0 :
144- let param = sig.n.sons[i].sym.copySym
145- param.typ = tConcrete
146- result .n.sons[i] = newSymNode (param)
147- result .sons[i] = tConcrete
148- else :
149- result .sons[i] = tOrig
150- if i > 0 : result .n.sons[i] = sig.n.sons[i]
151-
152127proc generateInstance (c: PContext , fn: PSym , pt: TIdTable ,
153128 info: TLineInfo ): PSym =
154129 # no need to instantiate generic templates/macros:
@@ -182,12 +157,8 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
182157 n.sons[genericParamsPos] = ast.emptyNode
183158 # semantic checking for the parameters:
184159 if n.sons[paramsPos].kind != nkEmpty:
185- if false and nimdbg:
186- result .typ = applyConcreteTypesToSig (fn, entry.concreteTypes)
187- addParams (c, result .typ.n, fn.kind)
188- else :
189- removeDefaultParamValues (n.sons[ParamsPos ])
190- semParamList (c, n.sons[ParamsPos ], nil , result )
160+ removeDefaultParamValues (n.sons[ParamsPos ])
161+ semParamList (c, n.sons[ParamsPos ], nil , result )
191162 else :
192163 result .typ = newTypeS (tyProc, c)
193164 rawAddSon (result .typ, nil )
0 commit comments