a simple way to simulate covariance in generic types

This commit is contained in:
Zahary Karadjov 2017-04-28 17:40:57 +03:00
commit c981284ddc
2 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,11 @@
type
BaseObj = object of RootObj
DerivedObj = object of BaseObj
Container[T] = object
proc doSomething(c: Container[BaseObj or DerivedObj]) = discard
var t: Container[DerivedObj]
doSomething t