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

Avoid to generate duplicated variable name #231

Merged
merged 15 commits into from
Apr 18, 2023

Conversation

fummicc1
Copy link
Collaborator

@fummicc1 fummicc1 commented Apr 14, 2023

Overview

If mockable has multiple initializer which have same parameter name, output mock can't be built due to conflict of variable name.

This fix aims to solve #224 .

After fix

  • Input
/// @mockable
protocol MyProtocol {
    init(param: Any)
    init(param: String)
    init(param: any Sequence<Character>)
}
  • Output
class MyProtocolMock: MyProtocol {
        private var _param: Any!
    init() { }
    required init(param: Any) {
        self._param = param
    }
    required init(param: String = "") {
        self._param = param
    }
    required init(param: any Sequence<Character>) {
        self._param = param
    }


}

@fummicc1 fummicc1 changed the title Avoid duplicated variable name for init Avoid to generate duplicated variable name Apr 14, 2023
@fummicc1 fummicc1 marked this pull request as ready for review April 15, 2023 11:57
@fummicc1 fummicc1 force-pushed the avoid-duplicated-var-name-for-init branch from 67e0701 to 92f6175 Compare April 15, 2023 13:36
@fummicc1 fummicc1 requested review from sidepelican and uhooi and removed request for sidepelican and uhooi April 15, 2023 14:00
Tests/TestInit/FixtureInit.swift Outdated Show resolved Hide resolved
Tests/TestInit/FixtureInit.swift Outdated Show resolved Hide resolved
Sources/MockoloFramework/Templates/ClassTemplate.swift Outdated Show resolved Hide resolved
Sources/MockoloFramework/Templates/ClassTemplate.swift Outdated Show resolved Hide resolved
fummicc1 and others added 5 commits April 18, 2023 21:40
Co-authored-by: Iceman <side.junktown@gmail.com>
Co-authored-by: Iceman <side.junktown@gmail.com>
Co-authored-by: Iceman <side.junktown@gmail.com>
Copy link
Collaborator

@sidepelican sidepelican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work!

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

Successfully merging this pull request may close these issues.

2 participants