mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
This resulted in a codegen error in C++ mode, because the generic types were not defined in modules where calls requiring downcasts were used (generating a downcast forces the inclusion of the full definition of the involved types).
15 lines
257 B
Nim
15 lines
257 B
Nim
type
|
|
Base[T] = ref object {.inheritable.}
|
|
value*: T
|
|
|
|
Derived[T] = ref object of Base[T]
|
|
derivedValue*: T
|
|
|
|
proc makeDerived*[T](v: T): Derived[T] =
|
|
new result
|
|
result.value = v
|
|
|
|
proc setBaseValue*[T](a: Base[T], value: T) =
|
|
a.value = value
|
|
|