tsubtypeconstraint.nim 308 B

1234567891011121314
  1. # bug #1684
  2. type
  3. BaseType {.inheritable pure.} = object
  4. idx: int
  5. DerivedType* {.final pure.} = object of BaseType
  6. proc index*[Toohoo: BaseType](h: Toohoo): int {.inline.} = h.idx
  7. proc newDerived(idx: int): DerivedType {.inline.} = DerivedType(idx: idx)
  8. let d = newDerived(2)
  9. assert(d.index == 2)