Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock is incorrect for protocol with constrained associatedType #1398

Open
alexdmotoc opened this issue Jan 9, 2025 · 0 comments
Open

Mock is incorrect for protocol with constrained associatedType #1398

alexdmotoc opened this issue Jan 9, 2025 · 0 comments

Comments

@alexdmotoc
Copy link
Contributor

Consider the following protocols:

// sourcery: AutoMockable
protocol SomeType {
    associatedtype List: ListType where List.Element == Domain
}

// sourcery: AutoMockable
protocol ListType {
    associatedtype Element: Identifiable
    func doStuff() -> [Element]
}

struct Domain: Identifiable {
    var id: Int
    var name: String
}

The generated SomeType is missing the constraint, so the code won't build:

class SomeTypeMock<
    List: ListType>: SomeType {
}

The correct version is:

class SomeTypeMock<
    List: ListType>: SomeType where List.Element == Domain {
}

This happens with the latest AutoMockable.stencil and sourcery 2.2.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant