Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added support for root typealiases#350

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
666tos wants to merge1 commit intoMakeAWishFoundation:master
base:master
Choose a base branch
Loading
from666tos:feature/root_typealias

Conversation

@666tos
Copy link

@666tos666tos commentedAug 25, 2023
edited
Loading

Mock template was customised to add single feature, which I namedroot-typealiases

Root typealiases are placed in root of the resulting file and are NOT nested inside type (as typealiases do).
They are meant to solve problem partially described in#184
Problem occurs when mock is generated for protocol name, which clashes with type from another library.
Since there is no concept of module inSourcery/SwiftyMocky, compiler gets confused which type should be used for inheritance, for example:

Typealias example:

Our module:

    //sourcery: root-typealias = "Feature = MyModule.Feature"    protocol Feature: AutoMockable {}

Another module:

    public struct Feature {}

ResultingMock.generated.swift:

    open class FeatureMock: Feature, Mock { <--- 'Feature' is ambiguous for type lookup in this context        public typealias Feature = MyModule.Feature    }

In this implementation this problem can be fixed by adding annotation for Feature protocol, like this:

    //sourcery: root-typealias = "Feature = MyModule.Feature"    protocol Feature: AutoMockable {}

ResultingMock.generated.swift:

    public typealias Feature = MyModule.Feature    open class FeatureMock: Feature, Mock {}  <--- No ambiguity for type lookup in this context

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@666tos

[8]ページ先頭

©2009-2025 Movatter.jp