blitz-foundation / monkey2

zlib License
3 stars 0 forks source link

Structs don't show constructors when GetDecls() is used #49

Open Pharmhaus-2 opened 5 years ago

Pharmhaus-2 commented 5 years ago

Original Author: DoctorWhoof

Not sure if a bug or expected behavior.

In the code below, the class and the struct are identical, but the Struct doesn't list the constructor when GetDecls() is used and the Class does.

Using the latest dev branch.

Namespace test

#Import "<reflection>"
#Reflect test..

Function Main()

    Local c := New TestClass
    For Local d := Eachin Variant( c ).Type.GetDecls()
        Print "~t" + d
    Next

    Print ""

    Local s := New TestStruct
    For Local d := Eachin Variant( s ).Type.GetDecls()
        Print "~t" + d
    Next

End

Class TestClass

    Field a:Int
    Field b:String

    Method Show()
        Print a + b
    End 

End

Struct TestStruct

    Field a:Int
    Field b:String

    Method Show()
        Print a + b
    End 

End

Cheers!