diff options
-rw-r--r-- | compiler/suggest.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/mimportutils.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/timportutils.nim | 11 |
3 files changed, 18 insertions, 3 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 829335015..41d39ccab 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -265,8 +265,8 @@ proc fieldVisible*(c: PContext, f: PSym): bool {.inline.} = if fmoduleId == module.id: return true if f.kind == skField: var symObj = f.owner - if symObj.typ.kind in {tyRef, tyPtr}: - symObj = symObj.typ[0].sym + if symObj.typ.skipTypes({tyGenericBody, tyGenericInst, tyGenericInvocation, tyAlias}).kind in {tyRef, tyPtr}: + symObj = symObj.typ.toObjectFromRefPtrGeneric.sym for scope in allScopes(c.currentScope): for sym in scope.allowPrivateAccess: if symObj.id == sym.id: return true diff --git a/tests/stdlib/mimportutils.nim b/tests/stdlib/mimportutils.nim index e89d58d27..678d9ec02 100644 --- a/tests/stdlib/mimportutils.nim +++ b/tests/stdlib/mimportutils.nim @@ -26,6 +26,12 @@ type H1*[T] = ref H2[T] H*[T] = H1[T] + Pity[T] = object + a: T + PityRef*[T] = ref Pity[T] + Hope*[T] = ref object + a: T + type BAalias* = typeof(B.default) # typeof is not a transparent abstraction, creates a `tyAlias` diff --git a/tests/stdlib/timportutils.nim b/tests/stdlib/timportutils.nim index be912e702..33afd7def 100644 --- a/tests/stdlib/timportutils.nim +++ b/tests/stdlib/timportutils.nim @@ -1,4 +1,4 @@ -import std/importutils +import std/[importutils, assertions] import stdtest/testutils import mimportutils @@ -134,5 +134,14 @@ template main = privateAccess PtA a.ha1 == 0 + block: + privateAccess PityRef + let x = PityRef[int](a: 1) # works + doAssert x.a == 1 + + privateAccess Hope + let y = Hope[int](a: 1) + doAssert y.a == 1 + static: main() main() |