Compiler exception when subclassing WindowAdapter

I encountred a problem when building a Swing application in Kotlin. I reduced it to a minimal test case which causes a compiler exception using M5.

import java.awt.event.*

class Foo() : WindowAdapter() {
  fun windowClosing(e : WindowEvent) {}
}


Additional information which may be helpful:

If “override” is added to the windowClosing function, it compiles and runs correctly.

The other 9 methods in WindowAdapter work without override. If override is added to any of them, there is a compiler error message about overridng “nothing”. I believe all the methods in WindowAdapter are concrete but empty.

Try using WindowEvent? type or Press Ctrl + N and choose override.

Dody, You are correct, changing to WindowEvent? produces a clean compile for the windowClosing function.

However, using WindowEvent? causes a compiler exception for the other methods. So now

class Foo() : WindowAdapter() {   fun windowOpened(e : WindowEvent?){} }

causes an exception, while with WindowEvent it works.

Clearly, something is broken and probably manifesting itself in multiple ways. Probably no need for further test cases. With a simple, repeatable test case, the bug should be easy to find.

Anyway, I have a workaround and am able to continue with my learning curve coding.

The nullable works because by default Kotlin treats everything from the Java side as a potential nullable value (unless you annotate it otherwise).

The easiest path is to have the IDE to generate the override signature for you so it will work. This is where the ctrl + N comes in.

Please, report bugs to the issue tracker. Thanks

http://youtrack.jetbrains.com/issue/KT-3360