IntelliJ-Luanalysis icon indicating copy to clipboard operation
IntelliJ-Luanalysis copied to clipboard

Illegal override when inheriting from a @shape

Open dcorbin opened this issue 4 years ago • 1 comments

Here is a sample lua file that shows the problem: https://gist.github.com/dcorbin/0eb0f273661e619873ffa13bf213974c

Interestingly, if the SetupHandler has only one @field, everything seems fine. Note also, on the error on line 40 that comes and goes with the multiple fields.

dcorbin avatar Feb 03 '21 14:02 dcorbin

This is a weird one.

Technically fun(self: LocationSetupHandler, object: tts__Object, configuration: GameConfiguration, extraStorage: tts__Bag): void is not assignable to a field of type fun(self: SetupHandler, object: tts__Object, configuration: GameConfiguration, extraStorage: tts__Bag): void

This is because the latter is callable with any SetupHandler passed as the first arg, where as the former specifically requires a LocationSetupHandler.

I guess I need to add some more special case handling for self.

Does seem a bit strange though, as if you just grab that field from the shape, it looks like a 4 param callback function, but it's not, it'll only work if called on the correct type. 😕

Benjamin-Dobell avatar Mar 24 '21 20:03 Benjamin-Dobell