tgenericsubtype.nim 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. block: # has generic field
  2. type
  3. Foo[T] = object of RootObj
  4. x: T
  5. Bar = object of Foo[int]
  6. proc foo(x: typedesc[Foo]) = discard
  7. foo(Bar)
  8. block: # no generic field
  9. type
  10. Foo[T] = object of RootObj
  11. Bar = object of Foo[int]
  12. proc foo(x: typedesc[Foo]) = discard
  13. foo(Bar)
  14. block: # issue #22445
  15. type
  16. MyType = ref object of RootObj
  17. MyChild[T] = ref object of MyType
  18. var curr = MyChild[int]()
  19. doAssert not(curr of MyChild[float])
  20. doAssert curr of MyChild[int]
  21. doAssert curr of MyType
  22. block: # issue #18861, original case
  23. type
  24. Connection = ref ConnectionObj
  25. ConnectionObj = object of RootObj
  26. ConnectionRequest = ref ConnectionRequestObj
  27. ConnectionRequestObj = object of RootObj
  28. redis: Connection
  29. ConnectionStrBool = distinct bool
  30. ConnectionRequestT[T] = ref object of ConnectionRequest
  31. ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
  32. keepttl: bool
  33. proc execute(req: ConnectionRequest): bool = discard
  34. proc execute(req: ConnectionRequestT[bool]): bool = discard
  35. proc execute(req: ConnectionRequestT[ConnectionStrBool]): bool = discard
  36. proc testExecute() =
  37. var connection: ConnectionSetRequest
  38. let repl = connection.execute()