mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 03:02:31 +00:00
Merge pull request #3666 from trustable-code/PR10
Fix multimethods issue #3550
This commit is contained in:
@@ -19,10 +19,7 @@ proc genConv(n: PNode, d: PType, downcast: bool): PNode =
|
||||
if (source.kind == tyObject) and (dest.kind == tyObject):
|
||||
var diff = inheritanceDiff(dest, source)
|
||||
if diff == high(int):
|
||||
# see bug #3550 which triggers it. XXX This is a hack but I don't know yet
|
||||
# how the real fix looks like:
|
||||
localError(n.info, "there is no subtype relation between " &
|
||||
typeToString(d) & " and " & typeToString(n.typ))
|
||||
# no subtype relation, nothing to do
|
||||
result = n
|
||||
elif diff < 0:
|
||||
result = newNodeIT(nkObjUpConv, n.info, d)
|
||||
|
||||
19
tests/method/tmultim8.nim
Normal file
19
tests/method/tmultim8.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
# bug #3550
|
||||
|
||||
type
|
||||
BaseClass = ref object of RootObj
|
||||
Class1 = ref object of BaseClass
|
||||
Class2 = ref object of BaseClass
|
||||
|
||||
method test(obj: Class1, obj2: BaseClass) =
|
||||
discard
|
||||
|
||||
method test(obj: Class2, obj2: BaseClass) =
|
||||
discard
|
||||
|
||||
var obj1 = Class1()
|
||||
var obj2 = Class2()
|
||||
|
||||
obj1.test(obj2)
|
||||
obj2.test(obj1)
|
||||
Reference in New Issue
Block a user