t5602_inheritence.nim 498 B

12345678910111213141516171819202122232425
  1. discard """
  2. output: "seq[float]\n0"
  3. targets: "c cpp"
  4. """
  5. # https://github.com/nim-lang/Nim/issues/5602
  6. import typetraits, module_with_generics
  7. type
  8. Foo[T] = object of RootObj
  9. Bar[T] = object of Foo[seq[T]]
  10. proc p[T](f: Foo[T]): T =
  11. echo T.name
  12. var s: Bar[float]
  13. echo p(s).len # the bug was: p(s) should return seq[float], but returns float instead
  14. # Test overloading and code generation when
  15. # downcasting is required for generic types:
  16. var d = makeDerived(10)
  17. setBaseValue(d, 20)