Skip to content

Generated code has compile errors when swift language version is set to 6 in TestTarget #594

@PetrosDavtyan

Description

@PetrosDavtyan

In pure Swift 6 projects (when test target swift language version is set to 6) the generated mocks will fail to compile.
Even when I change Swift language version to 5 in test target, there is still some compile errors when in the code there is a class confirming to a generic protocol, for example.

internal protocol GlobalParameters: Sendable {}

internal protocol ParametersValidating {
    associatedtype Parameters: GlobalParameters
    func validate(parameters: Parameters) throws
}

internal struct SomeParameters: GlobalParameters {
    let someProperty: String
}

enum SomeError: Error {
    case global
}

internal class SomeParametersValidator: ParametersValidating {
    func validate(parameters: SomeParameters) throws {
        guard !parameters.someProperty.isEmpty else {
            throw SomeError.global
        }
    }
}

The screenshot of generated mock file can be found in attachment.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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