a simple way to simulate covariance in generic types
This commit is contained in:
parent
bc01835091
commit
c981284ddc
2 changed files with 17 additions and 1 deletions
11
tests/generics/tfakecovariance.nim
Normal file
11
tests/generics/tfakecovariance.nim
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue