Skip to content

Inheritance behavior with the typealias option #303

Description

@sidepelican

This is the expected test fixture.

@Fixture enum overrideParentPAT {
    /// @mockable
    protocol ProtocolA {
        associatedtype ContextType
    }
    /// @mockable(typealias: ContextType = Void)
    protocol ProtocolA2: ProtocolA {}

    /// @mockable(typealias: ContextType = Int)
    protocol ProtocolB {
        associatedtype ContextType
    }
    /// @mockable(typealias: ContextType = Void)
    protocol ProtocolB2: ProtocolB {}

    /// @mockable(typealias: ContextType = Int)
    protocol ProtocolC {
        associatedtype ContextType
    }
    /// @mockable
    protocol ProtocolC2: ProtocolC {}

    @Fixture enum expected {
        class ProtocolAMock: ProtocolA {
            init() { }

            typealias ContextType = Any
        }

        class ProtocolA2Mock: ProtocolA2 {
            init() { }

            typealias ContextType = Void
        }

        class ProtocolBMock: ProtocolB {
            init() { }

            typealias ContextType = Int
        }

        class ProtocolB2Mock: ProtocolB2 {
            init() { }

            typealias ContextType = Void
        }

        class ProtocolCMock: ProtocolC {
            init() { }

            typealias ContextType = Int
        }

        class ProtocolC2Mock: ProtocolC2 {
            init() { }

            typealias ContextType = Int
        }
    }
}

Current output:

class ProtocolAMock: ProtocolA {
    init() { }

    typealias ContextType = Any


}

class ProtocolA2Mock: ProtocolA2 {
    init() { }

    typealias ContextType = Any // should be Void


}

class ProtocolBMock: ProtocolB {
    init() { }

    typealias ContextType = Int
}

class ProtocolB2Mock: ProtocolB2 {
    init() { }

    typealias ContextType = Int // should be Void
}

class ProtocolCMock: ProtocolC {
    init() { }

    typealias ContextType = Int
}

class ProtocolC2Mock: ProtocolC2 {
    init() { }

    typealias ContextType = Int
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions