mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-22 00:41:28 +00:00
fixes #270
This commit is contained in:
@@ -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)
|
||||
|
||||
28
tests/compile/tobject3.nim
Normal file
28
tests/compile/tobject3.nim
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user