The problem is most likely that field1
is not in fact a CustomTextField. It is easy to confirm this with a breakpoint or some logging.
Remember, it is not enough to declare the class of something. That thing must actually be that class (polymorphism). An instance has a class, quite without regard for how you may cast or declare a variable that refers to it.