Wiki

Ticket #276 (closed defect: fixed)

Opened 13 years ago

Last modified 13 years ago

Overriding Form.ProcessCmdKey causes "no suitable method found to override"

Reported by: torial Owned by: Charles
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc: charles

Description

When the following code snippet is compiled, I get a "no suitable method found to override".

use System.Windows.Forms #from "System.Windows.Forms"

class DataExtractor inherits Form
    
    cue init
        base.init
        .text = 'SFX'
        .width = 800
        .height = 600
        
#bug.cobra(16): error: "DataExtractor.ProcessCmdKey(ref System.Windows.Forms.Message?, System.Windows.Forms.Keys)": no suitable method found to override
    def processCmdKey(msg as inout Message?, keyData as Keys) as bool is override,protected
        if keyData == Keys.F5
            return true
        return base.processCmdKey(inout msg,keyData)
        


class Program

    def main is shared
        has STAThread
        Application.run(DataExtractor())

However, if I remove the ? and make the Message not nilable, I get an error the indicates it knows about the function:

Cannot make param "msg" non-nil because the base method declares it is nilable. Change "msg" to "Message?", or change the base method.

Change History

Changed 13 years ago by Charles

  • status changed from new to assigned
  • owner set to Charles

Fix on the way.

Changed 13 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed

The correct override, which now works, is without the ? on Message:

def processCmdKey(msg as inout Message, keyData as Keys) as bool is override, protected

Fixed in changeset:2484

Thanks for the report.

Note: See TracTickets for help on using tickets.