1023: Incompatible Override


Description of Error

When overriding a method (replacing the super class’s method with your own of the same name) you are required to match input parameters and types, return type, access specifier and namespace exactly. If you don’t you’ll get this error.

Adobe’s Official Writeup

A function marked override must exactly match the parameter and return type declaration of the function it is overriding. It must have the same number of parameters, each of the same type, and declare the same return type. If any of the parameters are optional, that must match as well. Both functions must use the same access specifier (public, private, and so on) or namespace attribute as well.
(Adobe Error Reference)

Cause of the Error

The override keyword allows you to redefine a method or property of a parent class. For instance, you may override the toString() method of MovieClip if you’re extending MovieClip and want to trace out a more detailed description of your class. There are several requirements to using the override keyword:

1) You have to be overriding at the class level. You cannot override a function block that’s nested within a class method, nor can you override a function block of timeline code. Otherwise, you generate error 1010: The override attribute may only be used on class property definitions.

2) The method you’re attempting to override must exist within the parent class. If you extend MovieClip and attempt to create a method called test() and mark it override, you will generate error 1020: Method marked override must override another method.

3) The method you’re attempting to override must not be marked final. If it is you’ll generate error 1025: Cannot redefine a final method.

4) Finally, your override method must match the parameters and return type of the method it’s overriding – including access specifiers and namespace. Otherwise you’ll generate this error (1023: Incompatible override).

Solutions to the Error

If you’re overriding one of the super class’s methods, take a look at the access specifier (public, internal, protected) and the namespace, the input parameters and the return type. Make sure that your override matches the original method exactly in all of these.

Other Articles About This Error

If you’ve read a useful writeup of this issue elsewhere on the internet, leave a comment and I’ll add it to this list.

  1. No comments yet.

You must be logged in to post a comment.

  1. No trackbacks yet.