tinheritgenericparameter.nim 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. discard """
  2. cmd: "nim check --hints:off --warnings:off $file"
  3. action: "reject"
  4. nimout:'''
  5. tinheritgenericparameter.nim(36, 15) Error: Cannot inherit from: 'MyObject'
  6. tinheritgenericparameter.nim(36, 15) Error: Cannot inherit from: 'MyObject'
  7. tinheritgenericparameter.nim(36, 23) Error: object constructor needs an object type [error]
  8. tinheritgenericparameter.nim(36, 23) Error: expression '' has no type (or is ambiguous)
  9. tinheritgenericparameter.nim(37, 15) Error: Cannot inherit from: 'int'
  10. tinheritgenericparameter.nim(37, 15) Error: Cannot inherit from: 'int'
  11. tinheritgenericparameter.nim(37, 23) Error: object constructor needs an object type [error]
  12. tinheritgenericparameter.nim(37, 23) Error: expression '' has no type (or is ambiguous)
  13. '''
  14. """
  15. type
  16. MyObject = object
  17. HorzLayout[Base, T] = ref object of Base
  18. data: seq[T]
  19. VertLayout[T, Base] = ref object of Base
  20. data: seq[T]
  21. UiElement = ref object of RootObj
  22. a: int
  23. MyType[T] = ref object of RootObj
  24. data: seq[T]
  25. OtherElement[T] = ref object of T
  26. Child[T] = ref object of HorzLayout[UiElement, T]
  27. Child2[T] = ref object of VertLayout[T, UiElement]
  28. Child3[T] = ref object of HorzLayout[MyObject, T]
  29. Child4[T] = ref object of HorzLayout[int, T]
  30. static:
  31. var a = Child[int](a: 300, data: @[100, 200, 300])
  32. assert a.a == 300
  33. assert a.data == @[100, 200, 300]
  34. discard Child2[string]()
  35. discard Child3[string]()
  36. discard Child4[string]()
  37. discard OtherElement[MyType[int]]()