File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -627,8 +627,10 @@ proc transformConv(c: PTransf, n: PNode): PNode =
627627 of tyObject:
628628 let diff = inheritanceDiff (dest, source)
629629 if diff == 0 or diff == high (int ):
630- result = transform (c, n[1 ])
631- result .typ = n.typ
630+ if sameType (n.typ, n[1 ].typ):
631+ result = transform (c, n[1 ])
632+ else :
633+ result = transformSons (c, n)
632634 else :
633635 result = newTreeIT (
634636 if diff < 0 : nkObjUpConv else : nkObjDownConv,
@@ -638,8 +640,11 @@ proc transformConv(c: PTransf, n: PNode): PNode =
638640 of tyObject:
639641 let diff = inheritanceDiff (dest, source)
640642 if diff == 0 or diff == high (int ):
641- result = transform (c, n[1 ])
642- result .typ = n.typ
643+ if sameType (n.typ, n[1 ].typ):
644+ # the conversion doesn't modify the type, drop it
645+ result = transform (c, n[1 ])
646+ else :
647+ result = transformSons (c, n)
643648 else :
644649 result = newTreeIT (
645650 if diff < 0 : nkObjUpConv else : nkObjDownConv,
You can’t perform that action at this time.
0 commit comments