fix #16516 method dispatch for sink args (#16594)

* fix #16516

* fix comment

* Trigger build
This commit is contained in:
cooldome
2021-01-06 10:47:03 +00:00
committed by GitHub
parent d721f5ceca
commit 58b9191354
2 changed files with 34 additions and 1 deletions

View File

@@ -67,7 +67,7 @@ proc sameMethodBucket(a, b: PSym; multiMethods: bool): MethodResult =
while true:
aa = skipTypes(aa, {tyGenericInst, tyAlias})
bb = skipTypes(bb, {tyGenericInst, tyAlias})
if aa.kind == bb.kind and aa.kind in {tyVar, tyPtr, tyRef, tyLent}:
if aa.kind == bb.kind and aa.kind in {tyVar, tyPtr, tyRef, tyLent, tySink}:
aa = aa.lastSon
bb = bb.lastSon
else:

View File

@@ -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()