Browse Source

Generate an error on explicit typecast from class to classref or from classref to class

Pierre Muller 3 years ago
parent
commit
242056074f
1 changed files with 3 additions and 1 deletions
  1. 3 1
      compiler/ncnv.pas

+ 3 - 1
compiler/ncnv.pas

@@ -3168,7 +3168,9 @@ implementation
                                    (nf_internal in flags)
                                  ))
                                 )
-                               ) then
+                               ) or ((((resultdef.typ=objectdef) and (left.resultdef.typ=classrefdef))
+                                     or ((left.resultdef.typ=objectdef) and (resultdef.typ=classrefdef)))
+                                     and not (nf_internal in flags)) then
                            CGMessage2(type_e_illegal_type_conversion,left.resultdef.typename,resultdef.typename)
                          else
                            begin