summary refs log tree commit diff stats
path: root/tests/method/tmproto.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/method/tmproto.nim')
-rw-r--r--tests/method/tmproto.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/method/tmproto.nim b/tests/method/tmproto.nim
new file mode 100644
index 000000000..5d75cff1a
--- /dev/null
+++ b/tests/method/tmproto.nim
@@ -0,0 +1,25 @@
+type
+  Obj1 = ref object {.inheritable.}
+  Obj2 = ref object of Obj1
+
+method beta(x: Obj1): int
+
+proc delta(x: Obj2): int =
+  beta(x)
+
+method beta(x: Obj2): int
+
+proc alpha(x: Obj1): int =
+  beta(x)
+
+method beta(x: Obj1): int = 1
+method beta(x: Obj2): int = 2
+
+proc gamma(x: Obj1): int =
+  beta(x)
+
+doAssert alpha(Obj1()) == 1
+doAssert gamma(Obj1()) == 1
+doAssert alpha(Obj2()) == 2
+doAssert gamma(Obj2()) == 2
+doAssert delta(Obj2()) == 2