summary refs log tree commit diff stats
path: root/tests/method
diff options
context:
space:
mode:
authorcooldome <ariabushenko@gmail.com>2021-01-06 10:47:03 +0000
committerGitHub <noreply@github.com>2021-01-06 10:47:03 +0000
commit58b9191354aa99ac2d17f9a7db3bdf239c7bce6b (patch)
tree898a75a56588a230a8b4862d144ee433c97b8cc0 /tests/method
parentd721f5cecad90a0aa7e2ea144607ffafdf647e31 (diff)
downloadNim-58b9191354aa99ac2d17f9a7db3bdf239c7bce6b.tar.gz
fix #16516 method dispatch for sink args (#16594)
* fix #16516

* fix comment

* Trigger build
Diffstat (limited to 'tests/method')
-rw-r--r--tests/method/tmethod_issues.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/method/tmethod_issues.nim b/tests/method/tmethod_issues.nim
index 80f54caee..df4c3771a 100644
--- a/tests/method/tmethod_issues.nim
+++ b/tests/method/tmethod_issues.nim
@@ -2,6 +2,8 @@ discard """
   output: '''
 wof!
 wof!
+type A
+type B
 '''
 """
 
@@ -126,3 +128,34 @@ var obj2 = Class2()
 
 obj1.test(obj2) 
 obj2.test(obj1)
+
+
+# -------------------------------------------------------
+# issue #16516
+
+type
+  A = ref object of RootObj
+    x: int
+
+  B = ref object of A
+
+method foo(v: sink A, lst: var seq[A]) {.base,locks:0.} =
+  echo "type A"
+  lst.add v
+
+method foo(v: sink B, lst: var seq[A]) =
+  echo "type B"
+  lst.add v
+
+proc main() =
+  let
+    a = A(x: 5)
+    b: A = B(x: 5)
+
+  var lst: seq[A]
+
+  foo(a, lst)
+  foo(b, lst)
+
+main()
+