* revert changes to tests tgenerics.nim and tv3_generics.nim, as these shouldn't be modified, instead the code needs to be adapted to return the previous value

+ added parameter isGenericInstance to markUsed
* restored the previous calls to markUsed with isGenericInstance false
* markUsed with isGenericInstance is ignored for now, but it will be stored in the nimsuggest database later
This commit is contained in:
Nikolay Nikolov
2024-05-14 18:21:47 +03:00
parent 515d9edf70
commit 339e55a9b7
5 changed files with 13 additions and 7 deletions

View File

@@ -683,9 +683,11 @@ proc semResolvedCall(c: PContext, x: var TCandidate,
assert x.state == csMatch
var finalCallee = x.calleeSym
let info = getCallLineInfo(n)
markUsed(c, info, finalCallee, isGenericInstance = false)
onUse(info, finalCallee)
assert finalCallee.ast != nil
if x.hasFauxMatch:
markUsed(c, info, finalCallee)
markUsed(c, info, finalCallee, isGenericInstance = true)
onUse(info, finalCallee)
result = x.call
result[0] = newSymNode(finalCallee, getCallLineInfo(result[0]))
@@ -721,7 +723,7 @@ proc semResolvedCall(c: PContext, x: var TCandidate,
x.call.add tn
else:
internalAssert c.config, false
markUsed(c, info, finalCallee)
markUsed(c, info, finalCallee, isGenericInstance = true)
onUse(info, finalCallee)
result = x.call
@@ -789,7 +791,9 @@ proc explicitGenericSym(c: PContext, n: PNode, s: PSym): PNode =
var newInst = generateInstance(c, s, m.bindings, n.info)
newInst.typ.flags.excl tfUnresolved
let info = getCallLineInfo(n)
markUsed(c, info, newInst)
markUsed(c, info, s, isGenericInstance = false)
onUse(info, s)
markUsed(c, info, newInst, isGenericInstance = true)
onUse(info, newInst)
result = newSymNode(newInst, info)

View File

@@ -96,7 +96,7 @@ type
const
isNilConversion = isConvertible # maybe 'isIntConv' fits better?
proc markUsed*(c: PContext; info: TLineInfo, s: PSym; checkStyle = true)
proc markUsed*(c: PContext; info: TLineInfo, s: PSym; checkStyle = true; isGenericInstance = false)
proc markOwnerModuleAsUsed*(c: PContext; s: PSym)
template hasFauxMatch*(c: TCandidate): bool = c.fauxMatch != tyNone

View File

@@ -696,7 +696,9 @@ proc markOwnerModuleAsUsed(c: PContext; s: PSym) =
else:
inc i
proc markUsed(c: PContext; info: TLineInfo; s: PSym; checkStyle = true) =
proc markUsed(c: PContext; info: TLineInfo; s: PSym; checkStyle = true; isGenericInstance = false) =
if isGenericInstance:
return
let conf = c.config
incl(s.flags, sfUsed)
if s.kind == skEnumField and s.owner != nil:

View File

@@ -14,5 +14,5 @@ main()
discard """
$nimsuggest --tester $file
>def $1
def;;skProc;;tgenerics.printHelloValue.printHelloValue;;proc (hello: Hello[system.float]){.gcsafe, raises: <inferred> [].};;$file;;5;;5;;"";;100
def;;skProc;;tgenerics.printHelloValue;;proc (hello: Hello[printHelloValue.T]);;$file;;5;;5;;"";;100
"""

View File

@@ -14,5 +14,5 @@ main()
discard """
$nimsuggest --v3 --tester $file
>def $1
def;;skProc;;tv3_generics.printHelloValue.printHelloValue;;proc (hello: Hello[system.float]){.gcsafe, raises: <inferred> [].};;$file;;5;;5;;"";;100
def;;skProc;;tv3_generics.printHelloValue;;proc (hello: Hello[printHelloValue.T]);;$file;;5;;5;;"";;100
"""