summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorJason Beetham <beefers331@gmail.com>2021-09-14 11:34:52 -0600
committerGitHub <noreply@github.com>2021-09-14 19:34:52 +0200
commit172253cb551a475d7d32093e562521990e71a1ed (patch)
tree34fb74e45d9d09a4a700ce274a3476b406e48fbe /compiler
parentef390e6a68db74a61137d7690dd2b10ec3dee050 (diff)
downloadNim-172253cb551a475d7d32093e562521990e71a1ed.tar.gz
Dotborrow now works with generic distincts (#18848)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim4
-rw-r--r--compiler/semstmts.nim3
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 41381b057..ebdfe02f0 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1280,7 +1280,7 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
     if p != nil and p.selfSym != nil:
       var ty = skipTypes(p.selfSym.typ, {tyGenericInst, tyVar, tyLent, tyPtr, tyRef,
                                          tyAlias, tySink, tyOwned})
-      while tfBorrowDot in ty.flags: ty = ty.skipTypes({tyDistinct})
+      while tfBorrowDot in ty.flags: ty = ty.skipTypes({tyDistinct, tyGenericInst})
       var check: PNode = nil
       if ty.kind == tyObject:
         while true:
@@ -1412,7 +1412,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
   if ty.kind in tyUserTypeClasses and ty.isResolvedUserTypeClass:
     ty = ty.lastSon
   ty = skipTypes(ty, {tyGenericInst, tyVar, tyLent, tyPtr, tyRef, tyOwned, tyAlias, tySink})
-  while tfBorrowDot in ty.flags: ty = ty.skipTypes({tyDistinct})
+  while tfBorrowDot in ty.flags: ty = ty.skipTypes({tyDistinct, tyGenericInst})
   var check: PNode = nil
   if ty.kind == tyObject:
     while true:
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 364444c98..c2f05ccce 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1296,7 +1296,8 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
         incl a[2].flags, nfSem # bug #10548
     if sfExportc in s.flags and s.typ.kind == tyAlias:
       localError(c.config, name.info, "{.exportc.} not allowed for type aliases")
-    if tfBorrowDot in s.typ.flags and s.typ.kind != tyDistinct:
+
+    if tfBorrowDot in s.typ.flags and s.typ.skipTypes({tyGenericBody}).kind != tyDistinct:
       excl s.typ.flags, tfBorrowDot
       localError(c.config, name.info, "only a 'distinct' type can borrow `.`")
     let aa = a[2]