diff options
author | Araq <rumpf_a@web.de> | 2013-01-08 17:23:52 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-01-08 17:23:52 +0100 |
commit | 20a5e37169669702868341ed6e3266372cab9eba (patch) | |
tree | cdefa20b8bf635a16aa82fab29af24d792113f31 | |
parent | f280ed1560b3b95bfe7fdea0c74b6e6a012a91dc (diff) | |
download | Nim-20a5e37169669702868341ed6e3266372cab9eba.tar.gz |
fixes #270
-rwxr-xr-x | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | tests/compile/tobject3.nim | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index cb0dcfe00..26144c152 100755 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1648,7 +1648,7 @@ proc downConv(p: BProc, n: PNode, d: var TLoc) = initLocExpr(p, n.sons[0], a) var r = rdLoc(a) if skipTypes(n.sons[0].typ, abstractInst).kind in {tyRef, tyPtr, tyVar} and - n.sons[0].kind notin {nkHiddenAddr, nkAddr}: + n.sons[0].kind notin {nkHiddenAddr, nkAddr, nkObjDownConv}: app(r, "->Sup") for i in countup(2, abs(inheritanceDiff(dest, src))): app(r, ".Sup") r = con("&", r) diff --git a/tests/compile/tobject3.nim b/tests/compile/tobject3.nim new file mode 100644 index 000000000..935e6ca8c --- /dev/null +++ b/tests/compile/tobject3.nim @@ -0,0 +1,28 @@ +type + TFoo = ref object of TObject + Data: int + TBar = ref object of TFoo + nil + TBar2 = ref object of TBar + d2: int + +template super(self: TBar): TFoo = self + +template super(self: TBar2): TBar = self + +proc Foo(self: TFoo) = + echo "TFoo" + +#proc Foo(self: TBar) = +# echo "TBar" +# Foo(super(self)) +# works when this code is uncommented + +proc Foo(self: TBar2) = + echo "TBar2" + Foo(super(self)) + +var b: TBar2 +new(b) + +Foo(b) |