summary refs log tree commit diff stats
path: root/tests/generics/t5602_inheritence.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generics/t5602_inheritence.nim')
-rw-r--r--tests/generics/t5602_inheritence.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/generics/t5602_inheritence.nim b/tests/generics/t5602_inheritence.nim
new file mode 100644
index 000000000..ee5ba89d5
--- /dev/null
+++ b/tests/generics/t5602_inheritence.nim
@@ -0,0 +1,24 @@
+discard """
+  output: "seq[float]\n0"
+  targets: "c cpp"
+"""
+
+# https://github.com/nim-lang/Nim/issues/5602
+
+import typetraits, module_with_generics
+
+type
+  Foo[T] = object of RootObj
+  Bar[T] = object of Foo[seq[T]]
+
+proc p[T](f: Foo[T]): T =
+  echo T.name
+
+var s: Bar[float]
+echo p(s).len # the bug was: p(s) should return seq[float], but returns float instead
+
+# Test overloading and code generation when
+# downcasting is required for generic types:
+var d = makeDerived(10)
+setBaseValue(d, 20)
+