blitz-foundation / monkey2

zlib License
3 stars 0 forks source link

error C2352: illegal call of non-static member function #45

Closed Pharmhaus-2 closed 5 years ago

Pharmhaus-2 commented 5 years ago

Original Author: engor

I tried to show confirm "Really close app?" right inside of OnWindowEvent and got compile-time error.

C:/proj/monkey2/monkey2fork/tmp/untitled1.buildv1.1.08/windows_release_msvc/src/untitled1_untitled1.cpp(42): error C2352: 't_mojo_app_Window::m_OnWindowEvent': illegal call of non-static member function
C:/proj/monkey2/monkey2fork/modules/mojo/mojo.buildv1.1.08/windows_release_msvc/include/mojo_app_2window.h(105): note: see declaration of 't_mojo_app_Window::m_OnWindowEvent'

I can live with that - by directly call to App.Terminate().

Look at demo app:

Namespace myapp

#Import "<std>"
#Import "<mojo>"
#Import "<mojox>"

Using std..
Using mojo..
Using mojox..

Class MyWindow Extends Window

    Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )

        Super.New( title,width,height,flags )
    End

    Method OnWindowEvent( event:WindowEvent ) Override

        If event.Type=EventType.WindowClose
            New Fiber( Lambda()
                Local ok:=RequestOkay( "Really close app?" )
                If Not ok Return
                ' comment me to work:
                Super.OnWindowEvent( event )
                ' uncomment me to work
                'App.Terminate()
            End )
        Else
            Super.OnWindowEvent( event )
        Endif
    End

End

Function Main()

    New AppInstance

    New MyWindow

    App.Run()
End
Pharmhaus-2 commented 5 years ago

MCVE:

Namespace myapp

#Import "<std>"

Using std..

Class BaseClassDef

    Method Beep() Virtual
        Print "BaseClassDef Beep"
    End

End

Class ClassDef Extends BaseClassDef

    Method ErrorMethod()
        Local x:=Lambda()
            Super.Beep() 'Self is captured but Super is not
            'Self.Beep()
        End
    End

    Method Beep() Override
        Print "ClassDef Beep"
    End
End

Function Main()
    Local c:=New ClassDef
    c.ErrorMethod()
End
Pharmhaus-2 commented 5 years ago

@engor Fixed in develop