diff options
-rw-r--r-- | compiler/liftdestructors.nim | 5 | ||||
-rw-r--r-- | tests/arc/tarc_orc.nim | 25 |
2 files changed, 28 insertions, 2 deletions
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim index 0e3518c5f..f62927cec 100644 --- a/compiler/liftdestructors.nim +++ b/compiler/liftdestructors.nim @@ -222,7 +222,10 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode; enforceDefaultOp: bool) proc fillBodyObjTImpl(c: var TLiftCtx; t: PType, body, x, y: PNode) = if t.baseClass != nil: - fillBody(c, skipTypes(t.baseClass, abstractPtrs), body, x, y) + let obj = newNodeIT(nkHiddenSubConv, c.info, t.baseClass) + obj.add newNodeI(nkEmpty, c.info) + obj.add x + fillBody(c, skipTypes(t.baseClass, abstractPtrs), body, obj, y) fillBodyObj(c, t.n, body, x, y, enforceDefaultOp = false) proc fillBodyObjT(c: var TLiftCtx; t: PType, body, x, y: PNode) = diff --git a/tests/arc/tarc_orc.nim b/tests/arc/tarc_orc.nim index 594950d71..674ba0dbb 100644 --- a/tests/arc/tarc_orc.nim +++ b/tests/arc/tarc_orc.nim @@ -136,4 +136,27 @@ proc main2 = doAssert a.len == 2 doAssert b.len == 0 -main2() \ No newline at end of file +main2() + +block: + type + TestObj = object of RootObj + name: string + + TestSubObj = object of TestObj + objname: string + + proc `=destroy`(x: TestObj) = + `=destroy`(x.name) + + proc `=destroy`(x: TestSubObj) = + `=destroy`(x.objname) + `=destroy`(TestObj(x)) + + proc testCase() = + let t1 {.used.} = TestSubObj(objname: "tso1", name: "to1") + + proc main() = + testCase() + + main() |