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

Support for variadic types as method arguments #1241

Merged
merged 5 commits into from
Dec 19, 2023

Conversation

art-divin
Copy link
Collaborator

@art-divin art-divin commented Dec 17, 2023

Resolves #1222

Context

Currently it is not possible to mock a method which has a VarArg argument type. Neither it is possible to mock a method or variable, whose return type contains a closure with a VarArg argument.

For example, the following code would not consider ... after the type:

func string(key: String, args: CVarArg...) -> String

Solution

Check if the MethodParameter is variadic, and if so, append ... after the TypeName.name.

@art-divin art-divin added the bug label Dec 17, 2023
@art-divin art-divin added this to the 2.1.3 milestone Dec 17, 2023
@art-divin art-divin self-assigned this Dec 17, 2023
@art-divin art-divin changed the title Support for variading types as method arguments Support for variadic types as method arguments Dec 17, 2023
@art-divin art-divin merged commit 7f85e02 into master Dec 19, 2023
2 checks passed
@art-divin art-divin deleted the fix-support-variading-types branch December 19, 2023 21:10
art-divin added a commit that referenced this pull request Dec 19, 2023
commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup
art-divin added a commit that referenced this pull request Dec 19, 2023
commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup
art-divin added a commit that referenced this pull request Dec 19, 2023
commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup
art-divin added a commit that referenced this pull request Dec 20, 2023
* updated automockable stencil template

* updated expected AutoMockable

* updated CHANGELOG

* added supported case for vararg

* Added example protocols for overrides

* More flexible support for overridden return types

* Added support for closure return type

* Added more methods for tests

* updated AutoMockable.expected

* reverted wrong trailing whitespace trimming

* added missing member lookup

* Squashed commit of the following:

commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup

* Squashed commit of the following:

commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup

* Squashed commit of the following:

commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup

* Revert "Merge branch 'master' into support-method-overriding"

This reverts commit 3c81133, reversing
changes made to 48816e2.

* Revert "Squashed commit of the following:"

This reverts commit 4f7d246.

# Conflicts:
#	Templates/Tests/Expected/AutoMockable.expected

* Updated AutoMockable.expected
art-divin added a commit that referenced this pull request Jan 10, 2024
commit 71c2d46
Author: rokridi <[email protected]>
Date:   Tue Jan 9 11:08:43 2024 +0100

    [#1251] Swifty generated variable names + fixed generated mocks compilation issues due to method generic parameters (#1252)

commit b62a8fc
Author: Igor Savelev <[email protected]>
Date:   Sat Jan 6 04:13:56 2024 +0000

    Initialise Subscript's returnTypeName with TypeSyntax, not String (#1250)

commit c7b57bc
Author: Igor Savelev <[email protected]>
Date:   Thu Jan 4 17:17:21 2024 +0000

    Added isAsync and throws to Subscript (#1249)

    * Added isAsync and throws to Subscript

    * Updated Linux version of AutoMockable.swift

commit fe41343
Author: Igor Savelev <[email protected]>
Date:   Thu Jan 4 08:58:37 2024 +0000

    Added generic requirements and generic parameters to Subscript (#1242)

commit 23179e8
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 27 00:23:47 2023 +0400

    docs: update metadata for 2.1.3 release

commit e88363c
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 27 00:06:11 2023 +0400

    docs: update metadata for 2.1.3 release

commit d74237a
Author: Ruslan Alikhamov <[email protected]>
Date:   Tue Dec 26 10:25:35 2023 +0400

    update SwiftStencilKit & Stencil (#1246)

commit 510ba24
Author: Ruslan Alikhamov <[email protected]>
Date:   Sun Dec 24 01:16:03 2023 +0400

    Introduce package access level (#1245)

    * added package modifier

    * added tests for Variable

    * added tests for package access level

commit b11d2d3
Author: Ruslan Alikhamov <[email protected]>
Date:   Sat Dec 23 19:39:24 2023 +0400

    Add dynamic method modifier support (#1244)

    * added missing attributes to Attribute.Identifier enum

    * moved to Attribute.Identifier from raw strings in Method.swift

    * updated Method (linux version)

    * updated generated content

    * added unit tests for dynamic method modifier

    * added dynamic to Variable

    * updated generated runtime files

    * added tests for variable isDynamic

    * fixed compilation error

    * fixed compilation error

commit 07a8b28
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 04:35:37 2023 +0400

    Support method overriding in AutoMockable (#1240)

    * updated automockable stencil template

    * updated expected AutoMockable

    * updated CHANGELOG

    * added supported case for vararg

    * Added example protocols for overrides

    * More flexible support for overridden return types

    * Added support for closure return type

    * Added more methods for tests

    * updated AutoMockable.expected

    * reverted wrong trailing whitespace trimming

    * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Revert "Merge branch 'master' into support-method-overriding"

    This reverts commit 3c81133, reversing
    changes made to 48816e2.

    * Revert "Squashed commit of the following:"

    This reverts commit 4f7d246.

    # Conflicts:
    #	Templates/Tests/Expected/AutoMockable.expected

    * Updated AutoMockable.expected

commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup

commit db7cc85
Author: Ruslan Alikhamov <[email protected]>
Date:   Sun Dec 17 10:00:37 2023 +0400

    Fixed incorrect parsing of consequently declared "@" symbols (#1239)

    * Fixed bug with incorrect parsing of consequently declared "@" symbols

    * renamed `isMacros` to `isPropertyWrapper` for clarity

commit 1502c0f
Author: Igor Savelev <[email protected]>
Date:   Fri Dec 15 14:48:48 2023 +0000

    Fixed missing attributes in optional closure type name (#1237)

    * Fixed missing attributes in optional closure type name

    * Reverted changes in unwrappedTypeName

    * Added fix for implicitly unwrapped closures

    * Added forced brackets for optional existential and opaque types

    * Revert "Added forced brackets for optional existential and opaque types"

    This reverts commit 50ff6e7.

commit 717e0ba
Author: Krzysztof Zabłocki <[email protected]>
Date:   Mon Dec 4 14:42:17 2023 +0100

    Update README.md

commit 1642f1f
Author: Pavel Trafimuk <[email protected]>
Date:   Fri Dec 1 02:53:57 2023 +0300

    Reduced counts of collisions for cache srf filenames (#1231)

commit 184ee11
Author: Ruslan Alikhamov <[email protected]>
Date:   Mon Nov 27 00:43:34 2023 +0400

    Updated XcodeProj to 8.16.0 (#1228)

    * Updated XcodeProj to 8.16.0

    * Updated CHANGELOG
art-divin added a commit that referenced this pull request Jan 10, 2024
commit 5856e3b
Author: Ruslan Alikhamov <[email protected]>
Date:   Tue Jan 9 15:30:34 2024 -0500

    Update AutoMockable.expected (#1253)

    * updated automockable.expected

    * updated CHANGELOG

    * attempt to resolve issue on Linux

    * added missing example code for linux

commit 71c2d46
Author: rokridi <[email protected]>
Date:   Tue Jan 9 11:08:43 2024 +0100

    [#1251] Swifty generated variable names + fixed generated mocks compilation issues due to method generic parameters (#1252)

commit b62a8fc
Author: Igor Savelev <[email protected]>
Date:   Sat Jan 6 04:13:56 2024 +0000

    Initialise Subscript's returnTypeName with TypeSyntax, not String (#1250)

commit c7b57bc
Author: Igor Savelev <[email protected]>
Date:   Thu Jan 4 17:17:21 2024 +0000

    Added isAsync and throws to Subscript (#1249)

    * Added isAsync and throws to Subscript

    * Updated Linux version of AutoMockable.swift

commit fe41343
Author: Igor Savelev <[email protected]>
Date:   Thu Jan 4 08:58:37 2024 +0000

    Added generic requirements and generic parameters to Subscript (#1242)

commit 23179e8
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 27 00:23:47 2023 +0400

    docs: update metadata for 2.1.3 release

commit e88363c
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 27 00:06:11 2023 +0400

    docs: update metadata for 2.1.3 release

commit d74237a
Author: Ruslan Alikhamov <[email protected]>
Date:   Tue Dec 26 10:25:35 2023 +0400

    update SwiftStencilKit & Stencil (#1246)

commit 510ba24
Author: Ruslan Alikhamov <[email protected]>
Date:   Sun Dec 24 01:16:03 2023 +0400

    Introduce package access level (#1245)

    * added package modifier

    * added tests for Variable

    * added tests for package access level

commit b11d2d3
Author: Ruslan Alikhamov <[email protected]>
Date:   Sat Dec 23 19:39:24 2023 +0400

    Add dynamic method modifier support (#1244)

    * added missing attributes to Attribute.Identifier enum

    * moved to Attribute.Identifier from raw strings in Method.swift

    * updated Method (linux version)

    * updated generated content

    * added unit tests for dynamic method modifier

    * added dynamic to Variable

    * updated generated runtime files

    * added tests for variable isDynamic

    * fixed compilation error

    * fixed compilation error

commit 07a8b28
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 04:35:37 2023 +0400

    Support method overriding in AutoMockable (#1240)

    * updated automockable stencil template

    * updated expected AutoMockable

    * updated CHANGELOG

    * added supported case for vararg

    * Added example protocols for overrides

    * More flexible support for overridden return types

    * Added support for closure return type

    * Added more methods for tests

    * updated AutoMockable.expected

    * reverted wrong trailing whitespace trimming

    * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Revert "Merge branch 'master' into support-method-overriding"

    This reverts commit 3c81133, reversing
    changes made to 48816e2.

    * Revert "Squashed commit of the following:"

    This reverts commit 4f7d246.

    # Conflicts:
    #	Templates/Tests/Expected/AutoMockable.expected

    * Updated AutoMockable.expected

commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup

commit db7cc85
Author: Ruslan Alikhamov <[email protected]>
Date:   Sun Dec 17 10:00:37 2023 +0400

    Fixed incorrect parsing of consequently declared "@" symbols (#1239)

    * Fixed bug with incorrect parsing of consequently declared "@" symbols

    * renamed `isMacros` to `isPropertyWrapper` for clarity

commit 1502c0f
Author: Igor Savelev <[email protected]>
Date:   Fri Dec 15 14:48:48 2023 +0000

    Fixed missing attributes in optional closure type name (#1237)

    * Fixed missing attributes in optional closure type name

    * Reverted changes in unwrappedTypeName

    * Added fix for implicitly unwrapped closures

    * Added forced brackets for optional existential and opaque types

    * Revert "Added forced brackets for optional existential and opaque types"

    This reverts commit 50ff6e7.

commit 717e0ba
Author: Krzysztof Zabłocki <[email protected]>
Date:   Mon Dec 4 14:42:17 2023 +0100

    Update README.md

commit 1642f1f
Author: Pavel Trafimuk <[email protected]>
Date:   Fri Dec 1 02:53:57 2023 +0300

    Reduced counts of collisions for cache srf filenames (#1231)

commit 184ee11
Author: Ruslan Alikhamov <[email protected]>
Date:   Mon Nov 27 00:43:34 2023 +0400

    Updated XcodeProj to 8.16.0 (#1228)

    * Updated XcodeProj to 8.16.0

    * Updated CHANGELOG
art-divin added a commit that referenced this pull request Jan 13, 2024
commit 5856e3b
Author: Ruslan Alikhamov <[email protected]>
Date:   Tue Jan 9 15:30:34 2024 -0500

    Update AutoMockable.expected (#1253)

    * updated automockable.expected

    * updated CHANGELOG

    * attempt to resolve issue on Linux

    * added missing example code for linux

commit 71c2d46
Author: rokridi <[email protected]>
Date:   Tue Jan 9 11:08:43 2024 +0100

    [#1251] Swifty generated variable names + fixed generated mocks compilation issues due to method generic parameters (#1252)

commit b62a8fc
Author: Igor Savelev <[email protected]>
Date:   Sat Jan 6 04:13:56 2024 +0000

    Initialise Subscript's returnTypeName with TypeSyntax, not String (#1250)

commit c7b57bc
Author: Igor Savelev <[email protected]>
Date:   Thu Jan 4 17:17:21 2024 +0000

    Added isAsync and throws to Subscript (#1249)

    * Added isAsync and throws to Subscript

    * Updated Linux version of AutoMockable.swift

commit fe41343
Author: Igor Savelev <[email protected]>
Date:   Thu Jan 4 08:58:37 2024 +0000

    Added generic requirements and generic parameters to Subscript (#1242)

commit 23179e8
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 27 00:23:47 2023 +0400

    docs: update metadata for 2.1.3 release

commit e88363c
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 27 00:06:11 2023 +0400

    docs: update metadata for 2.1.3 release

commit d74237a
Author: Ruslan Alikhamov <[email protected]>
Date:   Tue Dec 26 10:25:35 2023 +0400

    update SwiftStencilKit & Stencil (#1246)

commit 510ba24
Author: Ruslan Alikhamov <[email protected]>
Date:   Sun Dec 24 01:16:03 2023 +0400

    Introduce package access level (#1245)

    * added package modifier

    * added tests for Variable

    * added tests for package access level

commit b11d2d3
Author: Ruslan Alikhamov <[email protected]>
Date:   Sat Dec 23 19:39:24 2023 +0400

    Add dynamic method modifier support (#1244)

    * added missing attributes to Attribute.Identifier enum

    * moved to Attribute.Identifier from raw strings in Method.swift

    * updated Method (linux version)

    * updated generated content

    * added unit tests for dynamic method modifier

    * added dynamic to Variable

    * updated generated runtime files

    * added tests for variable isDynamic

    * fixed compilation error

    * fixed compilation error

commit 07a8b28
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 04:35:37 2023 +0400

    Support method overriding in AutoMockable (#1240)

    * updated automockable stencil template

    * updated expected AutoMockable

    * updated CHANGELOG

    * added supported case for vararg

    * Added example protocols for overrides

    * More flexible support for overridden return types

    * Added support for closure return type

    * Added more methods for tests

    * updated AutoMockable.expected

    * reverted wrong trailing whitespace trimming

    * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Squashed commit of the following:

    commit 7f85e02
    Author: Ruslan Alikhamov <[email protected]>
    Date:   Wed Dec 20 01:10:31 2023 +0400

        Support for variadic types as method arguments (#1241)

        * Added support for variadic types as method arguments

        * Added changelog entry

        * added example protocol with varargs

        * support for vararg in return type's closure

        * added missing member lookup

    * Revert "Merge branch 'master' into support-method-overriding"

    This reverts commit 3c81133, reversing
    changes made to 48816e2.

    * Revert "Squashed commit of the following:"

    This reverts commit 4f7d246.

    # Conflicts:
    #	Templates/Tests/Expected/AutoMockable.expected

    * Updated AutoMockable.expected

commit 7f85e02
Author: Ruslan Alikhamov <[email protected]>
Date:   Wed Dec 20 01:10:31 2023 +0400

    Support for variadic types as method arguments (#1241)

    * Added support for variadic types as method arguments

    * Added changelog entry

    * added example protocol with varargs

    * support for vararg in return type's closure

    * added missing member lookup

commit db7cc85
Author: Ruslan Alikhamov <[email protected]>
Date:   Sun Dec 17 10:00:37 2023 +0400

    Fixed incorrect parsing of consequently declared "@" symbols (#1239)

    * Fixed bug with incorrect parsing of consequently declared "@" symbols

    * renamed `isMacros` to `isPropertyWrapper` for clarity

commit 1502c0f
Author: Igor Savelev <[email protected]>
Date:   Fri Dec 15 14:48:48 2023 +0000

    Fixed missing attributes in optional closure type name (#1237)

    * Fixed missing attributes in optional closure type name

    * Reverted changes in unwrappedTypeName

    * Added fix for implicitly unwrapped closures

    * Added forced brackets for optional existential and opaque types

    * Revert "Added forced brackets for optional existential and opaque types"

    This reverts commit 50ff6e7.

commit 717e0ba
Author: Krzysztof Zabłocki <[email protected]>
Date:   Mon Dec 4 14:42:17 2023 +0100

    Update README.md

commit 1642f1f
Author: Pavel Trafimuk <[email protected]>
Date:   Fri Dec 1 02:53:57 2023 +0300

    Reduced counts of collisions for cache srf filenames (#1231)

commit 184ee11
Author: Ruslan Alikhamov <[email protected]>
Date:   Mon Nov 27 00:43:34 2023 +0400

    Updated XcodeProj to 8.16.0 (#1228)

    * Updated XcodeProj to 8.16.0

    * Updated CHANGELOG
@rokridi
Copy link
Contributor

rokridi commented Jan 24, 2024

Hi @art-divin 👋

Is it possible to add isVariadic property to ClosureParameter type ?

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

Successfully merging this pull request may close these issues.

Protocol method with variadic parameter
2 participants