Skip to content

Generic class in another class generates broken c++ #7

@zeromus

Description

@zeromus

Try this c# code

class Foo {
    class Bar<T> { }
}

It will pretty much just go off the rails, generating the below code, which among other things, references type Bar which doesn't exist.

class Foo : public virtual Object{
    public:
    class Bar_T{
        private:
        template<typename T>
        class Bar_T_Base : private virtual Object{
            public:
            Bar::Bar_Base(){
            }
        };

        private:
        template<typename T, bool>
        class Bar_T  {
        };
        private:

        //Basic types template type
        template<typename T>
        class Bar_T<T, true> : private Bar_T_Base<T>{
        };
        private:

        //Generic template type
        template<typename T>
        class Bar_T<T, false> : private virtual Bar_T_Base<Object>{
        };
    };
};

I tried a non-generic nested type and it worked OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions