mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-12 12:19:40 +00:00
Follow up PR to #25700 @demotomohiro This doesn't seem to mirror your suggested approach completely. I still went with a recursive walk. Could probably add some kind of "clean types" and "dirty types" cache through this to minimize the recursions, but that seems like a little much.
This commit is contained in:
@@ -20,3 +20,51 @@ let dir = DirStruct()
|
||||
doAssert dir.root.kind == fsoDir
|
||||
doAssert dir.root.dirName == "/"
|
||||
doAssert dir.root.files.len == 0
|
||||
|
||||
block:
|
||||
type
|
||||
Opt[T] = object
|
||||
when T is ref:
|
||||
val: T
|
||||
x: int
|
||||
else:
|
||||
val: T
|
||||
x: string
|
||||
|
||||
DefaultOpt = ref object
|
||||
files: Opt[DefaultOpt]
|
||||
|
||||
OptDirStruct = object
|
||||
root = DefaultOpt()
|
||||
|
||||
let dir = OptDirStruct()
|
||||
doAssert dir.root.files.x is int
|
||||
|
||||
block:
|
||||
type
|
||||
Opt[T] = object
|
||||
when T is ref:
|
||||
x: int
|
||||
else:
|
||||
x: string
|
||||
|
||||
Foo[T] = object
|
||||
x: Opt[T]
|
||||
|
||||
Nested = ref object
|
||||
files: Foo[Nested]
|
||||
|
||||
let nested = Nested()
|
||||
doAssert nested.files.x.x is int
|
||||
|
||||
block:
|
||||
type
|
||||
Foo[T] = object
|
||||
x = sizeof(T)
|
||||
|
||||
Sized = ref object
|
||||
files: Foo[Sized]
|
||||
|
||||
let sized = Sized()
|
||||
doAssert sized.files.x == sizeof(Sized)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user